Skip to content

fix(intune): narrow rotation-failure detection and cap parse_content continuation size - #453

Closed
adamgell with Copilot wants to merge 3 commits into
mainfrom
copilot/adamgellcmtraceopen-review-questions
Closed

adamgell with Copilot wants to merge 3 commits into
mainfrom
copilot/adamgellcmtraceopen-review-questions

Conversation

Copilot AI commented Aug 3, 2026 •

Copy link
Copy Markdown
Contributor

Two correctness gaps from the PR #397 review: over-broad rotation-failure detection routing unrelated ISO-8601 logs to the Device Inventory parser, and a 1 MiB framing bound that only the tail path enforced (opening vs. tailing a file with a large record produced different framing).

Fix 1: Narrow rotation_header_states_failure

Removed the starts_with("failed ") and starts_with("unhandled ") arms. These would route any ISO-8601 log with a generic Failed to … header line to the rotation-failure parser. Only rotation-specific phrases are retained:

// Before — too broad:
lowered.contains("failed to rotate")
    || lowered.contains("rotation failed")
    || lowered.contains("failed to roll")
    || lowered.starts_with("failed ")      // removed
    || lowered.starts_with("unhandled ")   // removed

// After — rotation-specific only:
lowered.contains("failed to rotate")
    || lowered.contains("rotation failed")
    || lowered.contains("failed to roll")

.NET exception evidence (the other detection path in has_rotation_failure_signature) is unchanged. Two new negative tests cover the removed arms.

Fix 2: Apply 1 MiB continuation bound in parse_records

Added MAX_CONTINUATION_BYTES = 1 MiB to inventory/mod.rs, mirroring MAX_PENDING_LOGICAL_RECORD_BYTES in watcher/tail.rs. When appending a continuation line would push the accumulated message over the cap, parse_records force-completes the current record and starts a new orphan—matching the tail path's split behavior. Oversized single continuation lines are also truncated at the Unicode character boundary. Two new tests verify the cap holds for both RotationFailure and Harvester dialects.

Copilot AI added 2 commits August 3, 2026 05:46
Fix 1 (has_rotation_failure_signature breadth):
Remove the over-broad `starts_with("failed ")` and `starts_with("unhandled ")`
arms from `rotation_header_states_failure`. Any ISO-8601 log with a line like
"2026-07-30T10:15:00Z Failed to load configuration." would previously route
the entire file to the Device Inventory rotation-failure parser. Only the
rotation-specific phrases (failed to rotate / rotation failed / failed to roll)
and .NET exception evidence are retained. Two negative tests cover the removed
arms.

Fix 2 (continuation size asymmetry):
Add MAX_CONTINUATION_BYTES = 1 MiB to inventory/mod.rs, mirroring
MAX_PENDING_LOGICAL_RECORD_BYTES in watcher/tail.rs. parse_records now caps
accumulated continuations at the same bound: when appending a continuation
would exceed 1 MiB, the current record is force-completed and a new orphan is
started (oversized single lines are truncated at the byte boundary). Two tests
verify that both RotationFailure and Harvester dialects respect the cap.
Copilot AI changed the title [WIP] Resolve open questions from review comment on intended behavior fix(intune): narrow rotation-failure detection and cap parse_content continuation size Aug 3, 2026
Copilot AI requested a review from adamgell August 3, 2026 05:58
@adamgell

adamgell commented Aug 5, 2026

Copy link
Copy Markdown
Owner

Architecture audit split #452 into #506 (rotation detection) and #507 (shared bounded framing). This draft is not a merge candidate: its predicate narrowing is useful evidence for #506, but its framing half duplicates the production limit/algorithm, truncates oversized input, and does not establish lossless open-versus-tail equality. #506 will implement the small predicate correction first; #507 will replace the duplicated/unbounded paths with one shared lossless framer. Closing this draft unmerged rather than polishing a stopgap.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants