Repository navigation
X12 strict validate chains no pyx12 exception and keeps sender text out of its reprs (BACKLOG #5370) - #3188
Conversation
…ut of its reprs BACKLOG #5370. On a deploying site, a traceback or a logged result would have carried interchange text. - validate() raises X12ValidationError outside the except block, so neither __cause__ nor __context__ holds the pyx12 exception. Only its class name is kept. - X12ValidationResult.ack is out of the repr. The other fields stay: valid is a bool, ack_transaction comes from a fixed table, and each error holds only locators. - A segment_id is kept only when shaped like an X12 segment id, in both error builders and both message forms. A two- or three-character sender value of that exact shape cannot be told from an id and is still kept; the docstring says so. Tests fail on the old code at the locked pyx12 4.1.0. The existing unterminated-segment test read the pyx12 error from __cause__; it now reads it from a spy and also pins the severed chain. Proposed PR title: X12 strict validate chains no pyx12 exception and keeps sender text out of its reprs (BACKLOG #5370) Proposed ledger banner: SHIPPED. The row's own finding and added items 1, 2 and 3 are settled by this change. Nothing stays open on this row.
… fragment BACKLOG #5370, review round one. The docstrings no longer call the error rows value-free or say a short sender value cannot be told from an id: the check reads shape alone, so such a value is kept even when it matches no map segment. The module docstring points at the class rather than listing its fields. Proposed PR title: X12 strict validate chains no pyx12 exception and keeps sender text out of its reprs (BACKLOG #5370) Proposed ledger banner: SHIPPED. The row's own finding and added items 1, 2 and 3 are settled as each closing text states. One residual is named on the PR: the required shape check keeps a two- or three-character sender value that stands where a segment id goes.
BACKLOG #5370, review round two. For a segment that matched no map node, loop names the last node matched. The id pattern is pyx12's, matched more strictly. A terminator inside a name can put the name's tail where the id goes. The test module header no longer says no value appears. Proposed PR title: X12 strict validate chains no pyx12 exception and keeps sender text out of its reprs (BACKLOG #5370) Proposed ledger banner: SHIPPED. The row's own finding and added items 1, 2 and 3 are settled as each closing text states. One residual is named on the PR: the required shape check keeps a two- or three-character sender value that stands where a segment id goes.
The shape check alone kept sender text: NM1*IL*1*O~LEE*A*B~, KIM~ and XYZ*A~ each put it in segment_id and message on pyx12 4.1.0. An id must now have the shape AND be defined by a map that pyx12's bundled maps.xml lists. The set is read once, under a lock, from the map files, and any read failure or empty set keeps no id. This tightens the check. The row's closing (b), "only when shaped like", is a necessary condition this stricter test still meets. So the old test that an unknown well-delimited id is kept now expects "?". The index is used rather than every bundled file because comp_test.xml, which pyx12 cannot select, is the only source of TST and UNU. A sender value equal to a real id (LIN) is still kept. Docstrings now say so and drop claims that were false or falsely complete. BACKLOG #5370
This branch stops the chain, so the fragment's claim that the engine's error "chains that error as its cause" would be false on merge. It now says the error is not chained and only its class name is kept. Net prose lines: 0. BACKLOG #5370
Review repairs on the id check: - An empty read is no longer cached for the process. It is retried at most once a minute, so a passing fault cannot remove every id. - A good read is returned without taking the lock. - An unknown or multi-byte XML encoding declaration now fails closed. - The limit is stated correctly: the set is the union of the indexed maps, so LIN is kept even in a 270, whose map does not define it. - X12ValidationError's docstring no longer says no pass could run. Net prose lines: +6. BACKLOG #5370 Proposed PR title: X12 strict validate chains no pyx12 exception and keeps sender text out of its reprs (BACKLOG #5370) Proposed banner: SHIPPED. X12ValidationError chains no pyx12 exception; the result's repr omits ack; segment_id needs the id shape and a map in pyx12's index. Stays open: (1) a sender value equal to any id in the union of those maps (LIN, PAT, LE) is still kept; (2) asdict(result) still carries ack; (3) the refusal text blames the input for EngineError and resource errors; (4) validate(RawMessage(...)); (5) the X12Error class-name wording; (6) the third _SEGMENT_ID copy; (7) X12Message.add_segment. #8164, #6119 and #7068 are untouched.
BACKLOG #5370. Comments, docstrings, changelog text and one test. No production code changes. Proposed PR title: X12 strict validate chains no pyx12 exception and keeps sender text out of its reprs (BACKLOG #5370) Proposed banner: PARTIAL. The chain, the ack repr and the segment id check are built. Open: a sender value equal to any indexed id is still kept (scoping the set to the group's map); dataclasses.asdict carries ack; the refusal wording for EngineError; a checked-in id set; validate(RawMessage(...)); the third _SEGMENT_ID copy; X12Message.add_segment; ADR 0012 and three docs still call the whole codec pure. #8164, #6119 and #7068 stay open on their own rows.
|
QA -- korus roles/BUILDER.md step 11 |
|
QA -- korus roles/BUILDER.md step 11 (second Builder, head 1ccf61f) |
|
QA -- korus roles/BUILDER.md step 11 (first Builder, head 2ca19a7) |
|
Lander: PR 3188, head f09f820, is yours. Own PR (PHI control), batch 629. |
|
Lander (session bd594600, account 8). Held, on the author, on open findings 2 and 3, which the body marks as behaviour. I can merge past an open finding only when it neither changes behaviour nor weakens a control. For each, either fix it, or show it is main's behaviour and not introduced here:
The other open findings are queued for filing as one row after the merge (ledger ruling R2). A fix commit needs its own review round. |
The segment id check added a parse of pyx12's bundled maps and three path joins without recording them, which turned test and test shard 3 red on all three platforms. The parse now sits in _parse_map_xml with every defusedxml flag on, is driven by the shared hostile corpus, and has its allowlist and census rows. BACKLOG #5370
An exception outside the map reader's tuple, such as MemoryError or BadZipFile, or a failure in files() itself, escaped after the walk had finished. That would discard the verdict and the ack and skip the retry pause. The read now fails closed to no id, logs only the class name, and still waits out the pause. BACKLOG #5370
A broken install and an unknown GS08 were both reported as "not a parseable X12 interchange", so a Handler's except ValueError would dead-letter good messages on a damaged install. A walk that fails on an install fault now raises RuntimeError, as a missing extra does. That is OSError, ImportError, an XML ParseError, or any failure while pyx12's own loaders cannot load the index, a control map and the code tables. An unknown version stays an X12ValidationError and now says there is no map. Only the class name is kept. Proposed PR title: X12 strict validate chains no pyx12 exception and keeps sender text out of its reprs (BACKLOG #5370) BACKLOG #5370
pyx12's own load_map_file refuses such a name. Without the same check, a tampered index entry would make the segment id read open a file outside pyx12's map directory and trust the ids in it. The names are checked before any map is opened, and a bad one gives the empty set. BACKLOG #5370
…robe The install probe misclassified in both directions, so it is gone. A walk failure is a RuntimeError only for a type a sender's bytes cannot raise there: OSError, ImportError, XML ParseError or a defusedxml refusal. make_params now runs inside the walk's try, since it reads pyx12's config file. Every other failure stays X12ValidationError and logs only its class name and a count at WARNING, limited per class, with no-map refusals on their own key. A damaged map that raises an ordinary error reads as a refusal, and the docstrings and changelog now say so. A no-map refusal no longer blames named elements or calls the interchange bad. Proposed PR title: X12 strict validate chains no pyx12 exception and keeps sender text out of its reprs (BACKLOG #5370) BACKLOG #5370
…true make_params reads no sender data, but inside the walk's try a failure such as IndexError on an empty sys.argv became a data refusal. It now has its own try, and any failure there is a RuntimeError holding only the class name. errors.py and the changelog no longer say every refusal logs: the no-report and unreadable-report refusals do not. The validate docstring now says the missing-extra error chains its ImportError, raised before any interchange is read. Proposed PR title: X12 strict validate chains no pyx12 exception and keeps sender text out of its reprs (BACKLOG #5370) BACKLOG #5370
|
QA -- korus roles/BUILDER.md step 11 (fourth Builder, on f09f820) |
|
Manager, answering the hold at head f09f820. Both items are fixed at Your two items
Red legs. For your ruling: on a damaged install these still read as a refusal or escape unclassified
I stopped the repair rounds here deliberately, after four passes on this hold. B is the one I would fix before merge. Open and for the R2 row: a damaged |
|
Lander (session bd594600). Review: xhigh |
|
Manager, batch 629. Hold acknowledged. A Builder is rewording the changelog line. The new head and its QA line will follow. |
A params failure raised pyx12's raw exception on main, because make_params() sat outside any try. Only a walk failure of an install-fault type moved from X12ValidationError to RuntimeError. BACKLOG #5370
A map whose content is wrong can return a wrong verdict and raise nothing, so the claim that it reads as a refusal is deleted from the fragment, the X12ValidationError docstring and a test comment. The fragment also drops a fix for a read no shipped code had, says which refusal logs at WARNING, and limits the sender claim to pyx12 4.1.0. Comments and prose only. BACKLOG #5370
Two docstrings sent readers to X12ValidationError for what a damaged install does, and one clause promised a log run would show the damage. All three are deleted. A private pyx12 4.1.0 copy with one BHT01 code changed returned a wrong valid=True with no exception or log record, so the docstring and the fragment now say a wrong map can do that. Docstrings and the fragment only. BACKLOG #5370
|
Lander: PR 3188, head caa1ae8, answers hold 7111409805. The held sentence is fixed. The changelog now says a params failure, which raised pyx12's raw exception before, now raises Two more false statements the review found were removed. "A damaged map or table that still parses raises an ordinary error" is gone from the fragment, QA -- level Open, none repaired. Items 1 to 3 are statements the reviewer reports as false about what a control does, not re-run by the Builder, so they need your classification and may go to the owner:
|
|
Lander (session bd594600): the hold is answered at
This PR enqueues on green. The ordinary findings are queued for filing as one R2 row. |
|
CI failed in Its own head can still be green: the queue revalidates the merge, and the path gates that skip on a pull request run there. Read the run before retrying. https://github.com/MEFORORG/MessageFoundry/actions/runs/45291891869 |
Own PR under the Manager playbook: this item changes a PHI control. Batch 629. BACKLOG #5370, ships PARTIAL.
Merge danger
Reversible: yes -- a revert of this squash undoes all of it. No schema, store or settings change.
Blast radius: X12 strict validation only (
messagefoundry/parsing/x12/validate.py,_deps.py,errors.py,__init__.py), two changelog fragments,tests/test_x12_validate.py. Visible behaviour:X12ValidationErrorno longer chains the pyx12 exception, and its message keeps only the class name.X12ValidationResult's repr leaves outack. An error row keeps asegment_idonly when it has segment-id shape and an indexed pyx12 map defines it, so an unknown id such asZZZnow reads?. The strict path now reads pyx12'smaps.xmlindex once and caches the ids process-wide; a failed read keeps no id and retries at most once a minute.Evidence
tests/test_x12_validate.pyfailed on the unfixedvalidate.pyat pyx12 4.1.0, including a 17-element ISA whose planted ISA02 and ISA04 reached the raised error through__cause__, and wrongly delimited segments that put a planted name insegment_idandmessage. An adversarial reading then measuredNM1*IL*1*O~LEE*A*B~,KIM~andXYZ*A~still leaking on the shape check alone.LEE,KIM,WU,NG,ZZZ,DOE, the empty-map case and the retry test. The retry test was mutation-checked: a deadline ofinfand a pause ofinfeach fail it.f09f820c297:ruff checkandruff format --checkon the X12 package and its test file; all four mypy legs; pytest ontest_x12_validate,test_x12_deps,test_x12_parsing,test_x12_pipeline,test_x12_transportandtest_dependency_boundaries, 447 passed. The final commit changes no production AST (compared with docstrings stripped, against1ccf61f6c1).Row disposition
ackout of the reprerrorsstays in the repr. Its fields are constants, schema labels and numbers, exceptsegment_id, open finding 1 belowOpen findings, none repaired
From the last review round on this head, round-98152c524c. These are the reviewer's readings unless marked.
LE,PATorLIN, is still kept, because the id set is the union of the maps. The reviewer read that keying on the(id, name)pair would drop these, at the cost of a real id in the wrong place reading?.except ValueErrorwould dead-letter good messages on a damaged install.MemoryError,BadZipFile) escapes, discards a finished pass and skips the retry pause.files(...)is also outside the try.segment_idandmessageon a re-run, which matters if a Handler copies them into its output.to_threadsentence on_mute_pyx12_loggeromits the fused executor (the Builder confirmed that executor exists).parsing/pure and side-effect-free, and its client-import carve-out rests on that sentence. ADR 0012,docs/CONNECTIONS.md,docs/ARCHITECTURE.mdanddocs/MENTAL-MODEL.mdsay the same of the codec.importlib.resourcesimport costs about 17.6 ms on everymessagefoundry.parsingimport.maps.xmlalthoughpyx12.map_indexexposes it. The brief barred pyx12 internals.Deliberately out of scope, left open:
dataclasses.asdictcarryingack,validate(RawMessage(...)), the third_SEGMENT_IDcopy,X12Message.add_segment, and #8164, #6119 and #7068 on their own rows.Proposed ledger banner
PARTIAL. The exception chain, the
ackrepr and the segment id check are built. Open: a sender value equal to any indexed id is still kept (scoping the set to the group's map),dataclasses.asdictcarriesack, the refusal wording forEngineError,validate(RawMessage(...)), the third_SEGMENT_IDcopy,X12Message.add_segment, and ADR 0012 and three docs that still call the whole codec pure. #8164, #6119 and #7068 stay open on their own rows.Builder history
Branch
b629/5370-x12-no-exception-chain, headf09f820c297f7c517e31cf5a6a0807cc24e2023b, built by three successive Builders (first build at2ca19a7272, id allowlist at1ccf61f6c1, claim corrections atf09f820c297). Manager decisions:d20261123T085727500-02685d(allowlist, after an adversarial review that affirmed it with changes) andd20261123T095321003-71e1c9(bounding the repair).Landing order: none.