Skip to content

fix(skills): keep HAR capture usable after a bad action - #85085

Closed
Adolanium wants to merge 1 commit into
NousResearch:mainfrom
Adolanium:fix/har-derived-capture-and-derive
Closed

Adolanium wants to merge 1 commit into
NousResearch:mainfrom
Adolanium:fix/har-derived-capture-and-derive

Conversation

@Adolanium

Copy link
Copy Markdown

Summary

Follow-up to #70823 that does not overlap #85053 (redaction / scheme / CDP queryString).

The capture scripts currently die on a bad --action before the HAR is flushed, so a guessed selector produces no file. CDP attach drives pages[0] of contexts[0], and --goto navigates that tab, which can wipe the session Hermes is already using. Derivation also drops urlencoded form bodies (postData.params with no text) and prints base64 response samples undecoded.

Changes

  • scripts/har_actions.py: shared run_action with ValueError on malformed specs, plus choose_drive_page / flush_pending.
  • har_capture.py: close the Playwright context in finally so a failed action still writes a partial HAR.
  • har_capture_cdp.py: listen on every context (not one page), open a new tab for --goto, flush in-flight requests, still write the HAR if an action fails. Does not close the attached browser.
  • har_to_client.py: read postData.params when text is missing, decode content.encoding == "base64" before printing. postData: null is treated as empty (this subsumes fix(har-derived-api-client): handle postData: null in HAR entries #84977 if that is still open).
  • Tests exercise the real helpers/deriver. No source-reading asserts.

Left alone on purpose: header redaction, hardcoded https://, and CDP queryString: [] (#85053).

Verification

python -m pytest tests/skills/test_har_derived_api_client_skill.py -q
11 passed

python -m ruff check <changed Python files>
All checks passed

No live network. No Playwright needed for the tests.

Failed --action specs IndexError and skip context.close(), so the HAR
never lands. CDP attach drives pages[0] (and --goto navigates it), and
derivation drops form params and base64 response bodies.

Share a validated run_action helper, flush the Playwright HAR in
finally, listen on every CDP context, open a new tab for --goto, and
flush in-flight requests. har_to_client now reads params-only postData
and decodes base64 content.

Does not change header redaction, scheme printing, or CDP queryString
(NousResearch#85053). Null postData is handled by the new body helper.
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.

1 participant