Skip to content

fix: report invalid HAR archives cleanly - #356

Open
sean0407 wants to merge 1 commit into
simonw:mainfrom
sean0407:codex/extract-har-badzip
Open

sean0407 wants to merge 1 commit into
simonw:mainfrom
sean0407:codex/extract-har-badzip

Conversation

@sean0407

Copy link
Copy Markdown

Summary

extract_har
  open ZIP archive
+ catch BadZipFile
+ show a Click error and exit nonzero
  inspect HAR and extract matching files

Invalid input such as a plain text file currently raises an uncaught zipfile.BadZipFile from ZipFile(...). Convert it to a clear CLI error and add a regression test. Fixes #321.

Evidence

  • Before: The regression test fails against main; invalid input produces no user-facing Click error.
  • After: The same test passes: the command exits with status 1, prints Invalid ZIP archive, and includes no traceback.
  • How to test: python3 -m unittest -v test_extract_har from the python directory.

Merge Danger

Door: two-way

Blast Radius: narrow

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-15T19:59:48.517845Z d39acd4 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d39acd4acb

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread python/extract_har.py

with zipfile.ZipFile(harzip) as zf:
try:
archive = zipfile.ZipFile(harzip)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Catch BadZipFile raised while reading har.har

When a ZIP's central directory is valid but its har.har bytes fail CRC validation, ZipFile(harzip) succeeds and this new try ends, then zf.read("har.har") raises zipfile.BadZipFile outside the handler. Running the CLI on such a damaged HAR still produces an uncaught traceback and no Invalid ZIP archive message, so the clean-error handling needs to cover the initial member read as well.

Useful? React with 👍 / 👎.

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unhandled exception / crash (zipfile.BadZipFile) on non-zip input in python/extract_har.py

1 participant