feat: preserve element/composite errors and trigger SEG_8 once per segment - #182
Merged
Conversation
…gment
Previously, SEG-validator errors and seg-level errors emitted by the
composite validator (COMP_*) were collapsed to SEG_8 with their err_str
preserved, while element errors emitted SEG_8 inline per error. This
mixed two concerns: (1) which pyx12 codes survive in the err_handler
tree, and (2) when SEG_8 fires.
Refactor apply_segment_errors with a clearer routing rule:
* Element errors (ELE_*) and composite errors (COMP_*) — both carry
map_node — are preserved in err_ele.errors with their specific
pyx12 code AND trigger a single SEG_8_HAS_DATA_ELEMENT_ERRORS in
err_seg.errors.
* SEG-validator errors (map_node is None) collapse to that same
single SEG_8 (their specific codes are dropped per PR #161 spec
correctness). The first SEG-validator error's err_str / err_val is
preserved on the SEG_8 emission.
* Exactly one SEG_8 per segment regardless of how many child errors
fired.
Composite emissions in _composite.py now set map_node=self so the
composite error flows through the ele_error path (composite_if has
data_ele/name/seq — the right shape for err_ele).
Ack output (997/999) is byte-for-byte identical: the visitor dedup logic
emits IK3-04*8 / AK3-04*8 once per segment whether SEG_8 arrives once or
many times. Six resJson fixtures gain SEG_8 entries in their seg-level
errors arrays where they previously had empty arrays.
Adds three new ApplySegmentErrorsRouting tests covering single element
error, multiple element errors on one segment, and the no-error case.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
azoner
added a commit
that referenced
this pull request
May 6, 2026
…-layer testing, resJson regen) Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
ELE_*) and composite errors (COMP_*) are now preserved inerr_ele.errorswith their specific pyx12 codes AND trigger exactly oneSEG_8_HAS_DATA_ELEMENT_ERRORSinerr_seg.errors.map_node is None) collapse to that same singleSEG_8per PR fix: route seg-level validation errors through errh.seg_error #161 spec correctness.SEG_8per segment regardless of how many child errors fired (composite emissions now setmap_node=selfso they flow through theele_errorpath).SEG_8entries on segments that previously had empty seg-level error arrays.Test plan
pytest pyx12/test/— 600 passed (3 newApplySegmentErrorsRoutingcases: single element error, multiple element errors on one segment, no-error case)mypy --strict pyx12— clean (89 files)ruff check+ruff format --check— clean_test_997/_test_999cases)🤖 Generated with Claude Code