feat: migrate _composite.py + _segment.py producers to pyx12 codes (PR 3 of 6) - #177
Merged
Merged
Conversation
…R 3 of 6) Third slice of the X12 error code generalization plan. Composite and segment validators now emit pyx12 codes (COMP_1_*, SEG_3_*, etc.). Visitors translate via the ERROR_CODES table (PR 1) so 999/997 ack output is unchanged. JSON err_cde flips for composite/seg-level errors. Producer migration: pyx12/map_if/_composite.py (3 sites): - Mandatory composite missing: "1" -> COMP_1_MANDATORY_MISSING - Composite marked Not Used: "5" -> COMP_5_NOT_USED - Too many sub-elements: "3" -> COMP_3_TOO_MANY_SUBELEMENTS pyx12/map_if/_segment.py (3 sites): - Too many elements in segment: "3" -> SEG_3_TOO_MANY_ELEMENTS - Too many sub-elements in composite (segment-level check): "3" -> SEG_3_TOO_MANY_SUBELEMENTS - Syntax violations: "10" -> SEG_10_SYNTAX_EXCLUSIVE, "2" -> SEG_2_SYNTAX_RELATIONAL Updated 4 test_map_if assertions to expect pyx12 codes: - test_segment_length: SEG_3_too_many_elements - test_comp_required_fail1: COMP_1_mandatory_missing - test_comp_not_used_fail1: COMP_5_not_used - test_plb03_composite_missing: COMP_1_mandatory_missing resJson fixtures unchanged: re-running the regenerator helper made no diff, confirming no existing fixture exercised composite-level or segment-validator-level error paths. Walker / parser emissions (still raw X12 codes "1"/"2"/"3"/"4"/"SEG1"/etc.) migrate in PR 4. Verification: - pytest pyx12/test/: 579 passed (no count change) - mypy --strict pyx12: clean (88 files) - ruff check + format --check: clean 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.
Third slice of the X12 error code generalization plan. Composite and segment validators now emit pyx12 codes; visitors translate via the ERROR_CODES table so 999/997 ack output is unchanged.
Producer migration
pyx12/map_if/_composite.py(3 sites):\"1\"→COMP_1_MANDATORY_MISSING\"5\"→COMP_5_NOT_USED\"3\"→COMP_3_TOO_MANY_SUBELEMENTSpyx12/map_if/_segment.py(3 sites):\"3\"→SEG_3_TOO_MANY_ELEMENTS\"3\"→SEG_3_TOO_MANY_SUBELEMENTS\"10\"→SEG_10_SYNTAX_EXCLUSIVE,\"2\"→SEG_2_SYNTAX_RELATIONALTest updates
4
test_map_ifassertions updated to expect pyx12 codes:test_segment_length→SEG_3_too_many_elementstest_comp_required_fail1→COMP_1_mandatory_missingtest_comp_not_used_fail1→COMP_5_not_usedtest_plb03_composite_missing→COMP_1_mandatory_missingresJson fixtures
Unchanged. Re-running the regenerator helper made no diff, confirming no existing resJson fixture exercised composite-level or segment-validator-level error paths. The 39 remaining raw X12 codes in resJson are all from walker/parser emissions, which migrate in PR 4.
Test plan
Plan reference
~/.claude/plans/radiant-petting-steele.md— see PR 3 section.🤖 Generated with Claude Code