-
Notifications
You must be signed in to change notification settings - Fork 107
Description
Before opening, please confirm:
- I have searched for duplicate or closed issues.
- I have read the guide for submitting bug reports.
- I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.
Bug Category
Other
Describe the bug
Calls to cedar_policy::Entity::new
fails in android bindings generated using uniffi if the entity's attributes are not empty.
It works fine if the entity does not have attributes.
Expected behavior
I expected the entity to be created successfully when it gets called in the Kotlin code.
Reproduction steps
- Write rust code that creates an entity using
cedar_policy::Entity::new
. - Create android bindings using uniffi.
- Run the code in an android device or emulator.
Code Snippet
let test_entity = "Test::\"abc\"".parse().expect("parse resource uid");
let test_entity_attrs = HashMap::from([
(
"item1".to_string(),
RestrictedExpression::new_string("abc".to_string()),
),
("attr2".to_string(), RestrictedExpression::new_long(123)),
]);
// This call to Entity::new is what fails in the android binding
let test_entity = Entity::new(test_entity, test_entity_attrs, HashSet::new()).expect("build entity");
Log output
FATAL EXCEPTION: main
Process: com.example.exampleapp, PID: 15076
java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:590)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:886)
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:580)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:886)
Caused by: uniffi.android_bindings.InternalException: build entity: EntityAttrEvaluationError { uid: EntityUid(EntityUID { ty: EntityType(Name(InternalName { id: Id("Test"), path: [], loc: Some(Loc { span: SourceSpan { offset: SourceOffset(0), length: 4 }, src: "Test::\"abc\"" }) })), eid: Eid("abc"), loc: Some(Loc { span: SourceSpan { offset: SourceOffset(0), length: 11 }, src: "Test::\"abc\"" }) }), attr_or_tag: "item1", was_attr: true, err: RecursionLimit(RecursionLimitError { source_loc: None }) }
Additional configuration
No response
Operating System
Android
Additional information and screenshots
I think the issue is caused by cedar_policy
trying to use stacker::remaining_stack
in cedar-policy-core/src/evaludator.rs
around line 945 inside the stack_size_check
function. The
stacker::remaining_stackfunction will always return
None` when called in an adroid device or emulator.
I also made this repository for convenience when trying to reproduce the issue: https://github.com/rmarinn/cedar-android-bindings-bug.
We also tried it in Swift (also used uniffi
to create the bindings) and the same issue arises.