pyx12.error_codes
pyx12 error code registry.
Producers (validators in pyx12.map_if, the walker in pyx12.map_walker, and
the parser in pyx12.x12file) emit pyx12-internal error codes named
<LEVEL>_<X12_CODE>_<discriminator> (e.g. ELE_6_invalid_composite). Each
code maps to an ErrorCodeSpec in ERROR_CODES, which carries the level,
human-readable description, and the X12 4010 (AK) / 5010 (IK) codes to
emit in 997 / 999 / JSON output.
The table is the single source of truth: visitors look up the pyx12 code
to find the ack-output code, and any future remap (e.g. the historical
“SEG1” parser code routed to AK/IK “8”) is a one-line table entry rather
than inline visitor logic.
This is the PR 1 slice — the table is fully populated but no producer
yet emits these codes. Visitors fall back to legacy raw X12-code lookup
when ERROR_CODES.get(err_cde) returns None. Producers migrate
incrementally in PR 2-4; PR 5 drops the legacy fallback.
Functions
x12_code_for(err_cde[, prefer_5010])
|
Resolve a pyx12 error code to its X12 ack code. |
Module Contents
-
pyx12.error_codes.LevelT[source]
-
class pyx12.error_codes.ErrorCodeSpec[source]
Single entry in ERROR_CODES.
ak_code and ik_code are the X12 acknowledgement codes for 4010 (AK)
and 5010 (IK) output respectively. None means the code is not
surfaced in that channel (e.g. parser HL1/HL2/LX bypass the ack
today; preserve that behavior with both = None).
x12_description is the official X12 spec definition for the error code
(e.g., “Required Data Element Missing” for IK4-03 code “1”). Provides
cross-reference to the X12 Implementation Guide.
-
code: str[source]
-
level: LevelT[source]
-
description: str[source]
-
ak_code: str | None[source]
-
ik_code: str | None[source]
-
x12_description: str[source]
-
pyx12.error_codes.ELE_1_MANDATORY_MISSING = 'ELE_1_mandatory_missing'[source]
-
pyx12.error_codes.ELE_2_CONDITIONAL_MISSING = 'ELE_2_conditional_missing'[source]
-
pyx12.error_codes.ELE_3_TOO_MANY_ELEMENTS = 'ELE_3_too_many_elements'[source]
-
pyx12.error_codes.ELE_4_TOO_SHORT = 'ELE_4_too_short'[source]
-
pyx12.error_codes.ELE_5_TOO_LONG = 'ELE_5_too_long'[source]
-
pyx12.error_codes.ELE_6_INVALID_COMPOSITE = 'ELE_6_invalid_composite'[source]
-
pyx12.error_codes.ELE_6_TRAILING_SPACE = 'ELE_6_trailing_space'[source]
-
pyx12.error_codes.ELE_6_CONTROL_CHAR = 'ELE_6_control_char'[source]
-
pyx12.error_codes.ELE_6_INVALID_TYPE_CHAR = 'ELE_6_invalid_type_char'[source]
-
pyx12.error_codes.ELE_7_INVALID_CODE = 'ELE_7_invalid_code'[source]
-
pyx12.error_codes.ELE_7_REGEX_FAIL = 'ELE_7_regex_fail'[source]
-
pyx12.error_codes.ELE_8_INVALID_DATE = 'ELE_8_invalid_date'[source]
-
pyx12.error_codes.ELE_8_INVALID_DATE_RANGE = 'ELE_8_invalid_date_range'[source]
-
pyx12.error_codes.ELE_9_INVALID_TIME = 'ELE_9_invalid_time'[source]
-
pyx12.error_codes.ELE_9_INVALID_TIME_OF_DAY = 'ELE_9_invalid_time_of_day'[source]
-
pyx12.error_codes.ELE_10_SYNTAX_EXCLUSIVE = 'ELE_10_syntax_exclusive'[source]
-
pyx12.error_codes.ELE_12_TOO_MANY_REPETITIONS = 'ELE_12_too_many_repetitions'[source]
-
pyx12.error_codes.ELE_13_TOO_MANY_COMPONENTS = 'ELE_13_too_many_components'[source]
-
pyx12.error_codes.ELE_I10_NOT_USED = 'ELE_I10_NOT_USED'[source]
-
pyx12.error_codes.COMP_1_MANDATORY_MISSING = 'COMP_1_mandatory_missing'[source]
-
pyx12.error_codes.COMP_3_TOO_MANY_SUBELEMENTS = 'COMP_3_too_many_subelements'[source]
-
pyx12.error_codes.COMP_5_NOT_USED = 'COMP_5_not_used'[source]
-
pyx12.error_codes.SEG_1_SEGMENT_NOT_FOUND = 'SEG_1_segment_not_found'[source]
-
pyx12.error_codes.SEG_1_INVALID_SEG_ID = 'SEG_1_invalid_seg_id'[source]
-
pyx12.error_codes.SEG_1_LEADING_SPACE = 'SEG_1_leading_space'[source]
-
pyx12.error_codes.SEG_2_SYNTAX_RELATIONAL = 'SEG_2_syntax_relational'[source]
-
pyx12.error_codes.SEG_2_SEGMENT_NOT_USED = 'SEG_2_segment_not_used'[source]
-
pyx12.error_codes.SEG_2_LOOP_NOT_USED = 'SEG_2_loop_not_used'[source]
-
pyx12.error_codes.SEG_3_TOO_MANY_ELEMENTS = 'SEG_3_too_many_elements'[source]
-
pyx12.error_codes.SEG_3_TOO_MANY_SUBELEMENTS = 'SEG_3_too_many_subelements'[source]
-
pyx12.error_codes.SEG_3_MANDATORY_SEGMENT_MISSING = 'SEG_3_mandatory_segment_missing'[source]
-
pyx12.error_codes.SEG_3_MANDATORY_LOOP_MISSING = 'SEG_3_mandatory_loop_missing'[source]
-
pyx12.error_codes.SEG_4_LOOP_REPEAT_EXCEEDED = 'SEG_4_loop_repeat_exceeded'[source]
-
pyx12.error_codes.SEG_5_SEGMENT_REPEAT_EXCEEDED = 'SEG_5_segment_repeat_exceeded'[source]
-
pyx12.error_codes.SEG_8_HAS_DATA_ELEMENT_ERRORS = 'SEG_8_has_data_element_errors'[source]
-
pyx12.error_codes.SEG_8_SEGMENT_EMPTY = 'SEG_8_segment_empty'[source]
-
pyx12.error_codes.SEG_8_TRAILING_TERMINATORS = 'SEG_8_trailing_terminators'[source]
-
pyx12.error_codes.SEG_8_HL_COUNT_MISMATCH = 'SEG_8_hl_count_mismatch'[source]
-
pyx12.error_codes.SEG_8_HL_INVALID_PARENT = 'SEG_8_hl_invalid_parent'[source]
-
pyx12.error_codes.SEG_8_LX_COUNT_MISMATCH = 'SEG_8_lx_count_mismatch'[source]
-
pyx12.error_codes.SEG_10_SYNTAX_EXCLUSIVE = 'SEG_10_syntax_exclusive'[source]
-
pyx12.error_codes.ERROR_CODES: dict[str, ErrorCodeSpec][source]
-
pyx12.error_codes.x12_code_for(err_cde, prefer_5010=True)[source]
Resolve a pyx12 error code to its X12 ack code.
Returns None for codes that do not surface in the requested ack
channel (e.g. the SEG_8_HL_* parser codes that historically were
filtered out).
Falls through to err_cde unchanged when err_cde is not a pyx12
code (legacy X12 codes like “6” / “8” emitted by un-migrated
producers during the PR 1-4 transition). PR 5 removes that
fallthrough — once all producers emit pyx12 codes only, an unknown
err_cde is an error.
- Parameters:
-
- Return type:
str | None