Hi,
I may have found a bug when decoding uper to xer, where choice item name is wrong.
A small patch is proposed as well.
Versions
- rasn: 0.28.13
- OS: Linux
- Rust: stable
Steps to Reproduce
- Clone/run this minimal repro crate: rasn-xer-choice-repro
- Run:
cd rasn-xer-choice-repro
cargo run
Actual Behavior
Output contains:
<Msg><messageData><elementIds><constrainedData><clearanceType><approach /></clearanceType><assignedTime /></constrainedData></elementIds></messageData></Msg>
The child of elementIds is emitted as constrainedData.
Expected Behavior
Output should contain:
<Msg><messageData><elementIds><uM270><clearanceType><approach /></clearanceType><assignedTime /></uM270></elementIds></messageData></Msg>
The child of elementIds should be the CHOICE alternative name uM270.
Why this looks like an encoder label bug
- Semantic decode/encode is consistent at UPER level (same payload round-trips).
- The mismatch is in XER element naming for CHOICE items inside SEQUENCE OF.
Suspected Area
Likely interaction in src/xer/enc.rs among:
encode_sequence_of
encode_choice
field_tag_stack
entering_list_item_type
Hypothesis: list-item CHOICE encoding can fall back to a parent/sibling identifier from field_tag_stack (constrainedData) instead of using the CHOICE variant identifier (uM270).
Suggested Fix Direction
- Preserve CHOICE variant identifier context for list-item CHOICE emission.
- Avoid parent stack fallback when encoding list-item CHOICE variants.
- Add a regression test for
SEQUENCE OF CHOICE with sibling optional fields.
Proposed patch
https://github.com/k1ll3rb1z/rasn-xer-choice-repro/blob/main/rasn_encode_choice_list_item_fix.patch
Attached Repro
Thanks
Note: AI was used to find a patch for my project
Hi,
I may have found a bug when decoding uper to xer, where choice item name is wrong.
A small patch is proposed as well.
Versions
Steps to Reproduce
cd rasn-xer-choice-repro cargo runActual Behavior
Output contains:
The child of
elementIdsis emitted asconstrainedData.Expected Behavior
Output should contain:
The child of
elementIdsshould be the CHOICE alternative nameuM270.Why this looks like an encoder label bug
Suspected Area
Likely interaction in
src/xer/enc.rsamong:encode_sequence_ofencode_choicefield_tag_stackentering_list_item_typeHypothesis: list-item CHOICE encoding can fall back to a parent/sibling identifier from
field_tag_stack(constrainedData) instead of using the CHOICE variant identifier (uM270).Suggested Fix Direction
SEQUENCE OF CHOICEwith sibling optional fields.Proposed patch
https://github.com/k1ll3rb1z/rasn-xer-choice-repro/blob/main/rasn_encode_choice_list_item_fix.patch
Attached Repro
Thanks
Note: AI was used to find a patch for my project