Sharpen HAR parser error messages for method and url#2
Merged
Conversation
parse_har previously collapsed three failure modes into one message
("missing"): the key was absent, the value was wrong type, or the
value was an empty string. They point at different upstream bugs
(non-conformant HAR tool, corrupt capture, schema violation), so
they now produce three distinct messages each for both required
fields:
HAR entry[0] (<url>): request.method is missing.
HAR entry[0] (<url>): request.method must be a string, got int.
HAR entry[0] (<url>): request.method is empty.
The same split applies to request.url. Real-world HARs commonly
contain dozens of entries; v1 only parses entries[0], so the URL
parenthetical is what tells the user which captured request actually
failed in their archive. When the URL itself is the bad field the
label degrades to "HAR entry[0]:" without a parenthetical.
Tests cover all six failure paths plus the label-with-URL and
label-fallback cases. Lambda handler test still passes — its
assertion only checks for the substring "method" in the 400 detail.
CHANGELOG [Unreleased] / Fixed updated.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
marky224
added a commit
that referenced
this pull request
May 2, 2026
HAR-tab UX polish, Report action wiring, and parser hardening rolled up from PRs #2, #3, and the action-button work on this branch: - HAR picker meta line shows file size, capture date, unique-host count - Report Re-run / Export markdown buttons wired up (previously inert) - Lambda /api/analyze returns 400 with detail on malformed HAR entries - HAR parser distinguishes missing/wrong-type/empty for method+url - HAR httpVersion normalized to match live runner's protocol format schema_version stays at 1.0 — no Report shape changes.
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
parse_harnow distinguishes missing key vs wrong type vs empty string forrequest.methodandrequest.url— three failure modes that pointed at different upstream bugs but previously collapsed into one "missing" message.HAR entry[0] (<url>):so the user can identify which captured request failed (real-world HARs have many entries; v1 parses entries[0] only). Label degrades toHAR entry[0]:when the URL itself is the bad field./api/analyzeparser-rejection path on 2026-05-02; both items came back as cheap parser-only follow-ups.Example new messages:
Test plan
pytest— 335 passed, including 6 new tests covering all method/url failure paths plus the label-with-URL and label-fallback casesruff check .cleanruff format --check .cleanmypyclean🤖 Generated with Claude Code