fix(cli): validate profile array elements and name --storage-domain - #173
Merged
Merged
Conversation
Both auto-review nits from #152. profiles.json's object arrays (indexedDb, the pointer arrays, captureHeaders, domSelectors) were only Array.isArray-checked, so a typo inside an entry passed CLI validation and surfaced much later as a ProtocolError from the extension's hello validator, mid-pair, with no hint about which profile or entry was at fault. Each array now gets a per-element shape check that names the offending index. Deliberately structural (required fields present and string-typed): the protocol's format rules — origin scheme, key and selector character sets, JSON pointer syntax — stay in @fetchproxy/protocol, since two definitions of valid would drift. Storage reads target one declared domain. On a multi-domain profile with none picked, the message that reached the user came from the server and named the library option: "pass { domain: '<one of them>' }" — something no CLI user can pass. `fpx cookies|local-storage|session-storage|indexeddb` and `fpx dom` now refuse before connecting (like the existing --domain check in `fpx pair`), so the usage error costs no bridge round-trip and triggers no pairing. `fpx session` can't pre-check — a captureHeaders-only profile is legitimately multi-domain and never does a domain-scoped read — so mapBridgeError rewrites the server's message there instead, keeping the declared-domain list and swapping the hint for --storage-domain. That path now exits USAGE rather than BRIDGE, which is what it is. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011DKSBmZAgtkp3wfCB4TgMm
|
Claude finished @chrischall's task in 2m 19s —— View job Review complete
No issues found. This is a tight, well-scoped fix:
Verdict: pass |
Contributor
|
✅ Auto-review verdict: pass — Well-scoped fix that matches its description exactly: per-element profile validation aligns with the actual protocol decl shapes, and the storage-domain hint rewrite correctly matches the real server error string. No issues found. |
chrischall
enabled auto-merge (squash)
July 27, 2026 19:15
chrischall
added a commit
that referenced
this pull request
Jul 27, 2026
🤖 I have created a release *beep* *boop* --- ## [1.6.2](v1.6.1...v1.6.2) (2026-07-27) ### Bug Fixes * **cli:** validate profile array elements and name --storage-domain ([#173](#173)) ([871d87c](871d87c)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
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.
Both nits from the auto-review follow-up issue.
profiles.ts— per-element validationvalidateProfileonlyArray.isArray-checkedcaptureHeaders/indexedDb/localStoragePointers/sessionStoragePointers/domSelectors. A typo inside an entry passed CLI validation and failed much later at the extension's hello validator, mid-pair, with aProtocolErrorthat names neither the profile nor which entry was wrong. These arrays are the hand-edited ones — only--capture-headerand--dom-selectorhave flags — so they're exactly where a typo is likely.Each array now gets a per-element shape check, and the error names the index (
profile "x" has an invalid "indexedDb[1]").Deliberately structural: required fields present and string-typed. The protocol's format rules (origin scheme, key/selector character sets, JSON-pointer syntax) stay in
@fetchproxy/protocol's validator — duplicating them here would give two definitions of "valid" and they would drift.multi-domain reads — name the flag, not the library option
Storage reads target exactly one declared domain. With several declared and none picked, the message that reached the user came from the server:
There is no object for a CLI user to pass. Two changes:
fpx cookies|local-storage|session-storage|indexeddbandfpx domrefuse up front, next to the existing scope-narrowing checks, mirroringfpx pair's--domaincheck. Both verbs read unconditionally, so the gap is provable without connecting — and a usage error must not cost a bridge round-trip or trigger pairing. A test assertslisten()was never called.fpx sessioncan't pre-check: acaptureHeaders-only profile is legitimately multi-domain and never does a domain-scoped read (bootstraponly threadsstorageDomaininto the cookie/localStorage/sessionStorage/IDB reads). SomapBridgeErrorrewrites the server's message there — keeping the declared-domain list, swapping the hint for--storage-domain.One behavioural note: that rewritten path returns
EXIT.USAGE(1) instead ofEXIT.BRIDGE(2). It is a usage error — the bridge is fine, the invocation isn't — and a script distinguishing "retry" from "fix your command" was previously told the wrong one.Verification
npm run build && npm test(CI's exact commands): 982 passed,npm run typecheckclean. Six new tests; revertingpackages/cli/srcfails five of them (the sixth is the over-rejection guard, which correctly passes either way).Closes #152
🤖 Generated with Claude Code
https://claude.ai/code/session_011DKSBmZAgtkp3wfCB4TgMm