Repository navigation
fix(cli): advertise the source-location path and URL constraints - #9281
Merged
morluto merged 3 commits intoNov 9, 2026
Merged
Conversation
Contributor
[Low impact] The PR appears safe to merge, with a non-blocking correction needed to preserve the absolute-URL guidance. Findings
Fix with agent prompt### Issue 1
src/cli/webSourceLocationCommands.ts:31
Reusing `sourceMapSelection.shape.url` removes “Absolute” from the CLI help, but `admitContext` still requires an absolute URL through `URL.canParse` without a base. A value such as `app.js.map` passes the advertised nonempty-string check, then fails in the service.
Restore the absolute-URL requirement in the shared field’s description so callers can discover it before running the command.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.SummaryThe CLI now reuses the domain fields for the manifest path, map path, and map URL.
Reviews (5) · Last reviewed commit: "style(test): wrap input schema assertion..." · Reviewed by Greptile |
Shelden-Hao
marked this pull request as ready for review
November 7, 2026 15:16
This was referenced Nov 7, 2026
12 of 19 tasks
trace-web-source-location declared manifestPath, sourceMapPath and sourceMapUrl as bare strings, so `--schema --json` advertised them with no minLength and no absolute-path pattern. The service then refused a relative manifest or map with a post-parse invalid_request naming manifest_path and source_map.path, while trace-web-module-imports already advertises those constraints from its domain fields. Bind the three positionals to webSourceLocationInputSchema so the domain field owns the bounds, format and help, matching the rule in cliDecimalField that the domain field owns bounds, defaults, nullability and help. The CLI now refuses a relative or NUL-bearing value at its own boundary with a field-level message instead of surfacing a service-level failure. Add a boundary test that compiles the advertised args schema and asserts the shared path and non-empty URL constraints, next to the existing sibling case.
The boundary case for trace-web-source-location used "manifest\0.json", which is also a relative path. The absolute-path constraint alone rejects it, so the case would still pass if schema conversion dropped the NUL pattern. Use an absolute path with an embedded NUL instead, and add the same case for sourceMapPath.
The two unknown-byte cases exceeded the line width and tripped format:check in CI. No assertion changes.
Shelden-Hao
force-pushed
the
fix/cli-source-location-input-constraints
branch
from
November 8, 2026 14:12
4d431d8 to
f67737f
Compare
| .string() | ||
| .describe("Absolute source-map URL context; no fetch"), | ||
| sourceMapPath: sourceMapSelection.shape.path, | ||
| sourceMapUrl: sourceMapSelection.shape.url, |
Contributor
There was a problem hiding this comment.
Reusing sourceMapSelection.shape.url removes “Absolute” from the CLI help, but admitContext still requires an absolute URL through URL.canParse without a base. A value such as app.js.map passes the advertised nonempty-string check, then fails in the service.
Restore the absolute-URL requirement in the shared field’s description so callers can discover it before running the command.
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/cli/webSourceLocationCommands.ts
Line: 31
Comment:
**URL help drops a requirement**
Reusing `sourceMapSelection.shape.url` removes “Absolute” from the CLI help, but `admitContext` still requires an absolute URL through `URL.canParse` without a base. A value such as `app.js.map` passes the advertised nonempty-string check, then fails in the service.
Restore the absolute-URL requirement in the shared field’s description so callers can discover it before running the command.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.
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
Fixes #9201.
rea trace-web-source-locationdeclared three of its positionals as bare strings, so--schema --jsonadvertisedmanifestPath,sourceMapPathandsourceMapUrlwith nominLengthand no absolute-path pattern. A caller reading the advertised contract could not discover the constraint that the command actually enforces one parse later.Problem and expected behavior
Smallest trigger, on
mainat2e2f981:Before this change, the advertised args were:
Passing a relative manifest then failed one stage later, from
service.trace, not from the CLI argument parser:{"code":"invalid_request","category":"invalid_input","details":{"operation":"trace_web_source_location","issues":[ {"path":["manifest_path"],"reason":"invalid_format","message":"must be an absolute local filesystem path"}, {"path":["source_map","path"],"reason":"invalid_format","message":"must be an absolute local filesystem path"}]}}The violated invariant is that the advertised CLI input schema and the parsed domain input agree on the constraints of a selected local path.
trace-web-module-importsalready satisfies it by reusingwebModuleTraceInputSchemafields, andtests/boundary/cli/cliInputSchemaRequired.test.tsalready checks that sibling.Change and scope
src/cli/webSourceLocationCommands.tsnow binds the three positionals to their owning domain fields instead of restating them:manifestPath→webSourceLocationInputSchema.shape.manifest_pathsourceMapPath/sourceMapUrl→webSourceLocationInputSchema.shape.source_map.shape.{path,url}This follows the rule already recorded on
cliDecimalField: the domain field owns bounds, defaults, nullability and help. It also corrects two descriptions that disagreed with the contract —sourceMapPathgained the "no fetch" statement that the MCP schema carries, andsourceMapUrlno longer claims to be absolute, which the domain never required.The integer positionals (
scriptIndex,line,column) keepcliIntegerArgument, because those need the CLI decimal-token parsing that the domain field does not provide; their advertisedminimum/maximumalready match the domain bounds.A draft PR may leave the scope decision pending. This is a contract-consistency fix inside an existing capability: no new provider, no target execution, injection, memory mutation or protection recovery, so no maintainer scope decision is required.
I intentionally did not change other registrations that still declare bare path strings. Inspection of the sibling web-script workflow showed
trace-web-module-importsis already correct; the remaining sites are in unrelated command families and each needs its own contract check, so they do not belong in this diff.Contract and boundary impact
src/domain/webSourceLocation.tsstays the owner of the parsed facts. Only its consumer, the CLI registration, stops re-declaring them. No superseded code path remains; the duplicated literal descriptions are removed rather than kept in parallel.minLength: 1, the NUL-free pattern and the absolute-path pattern for both paths, andminLength: 1for the URL, matching thetrace_web_source_locationMCP contract. The alias→domain mapping inrunis unchanged, so the MCP surface is untouched.docs/public/product-catalog.json), package, or installation impact (CI generates and validates ignored catalogs andskills/; edit authored instructions in.agents/skills/reverse-engineer-anything/and never commit build outputs): none; no generated file was edited.Expected effects (check known effects; use documentation-only on its own).
Unchecked items do not establish absence; leave uncertainties visible.
Evidence and regression coverage
web source location CLI advertised input schemablock intests/boundary/cli/cliInputSchemaRequired.test.ts, next to the existingweb module CLI advertised input schemacase. It compiles the advertisedargsschema with Ajv2020 and asserts an absolute manifest and map are accepted, while an empty value, a relative value, a NUL-bearing value and an empty URL are rejected. The NUL cases carry a NUL inside an otherwise absolute path, for bothmanifestPathandsourceMapPath, so they pin the NUL pattern rather than being rejected by the absolute-path check alone.src/cli/webSourceLocationCommands.tsand re-running the same test file. The new case fails on the base source and passes with the change, so it pins this defect rather than the surrounding behavior.After the change,
trace-web-source-location --schema --jsonadvertises:(A Windows host was used, so the advertised absolute pattern is the Windows one; the POSIX host advertises its own.)
and a relative manifest now fails at the CLI boundary with a field-level message instead of a service-level
invalid_request:{"code":"VALIDATION_ERROR","message":"REA could not read the command arguments. Check the named argument and its expected type, then try again.","fieldErrors":[ {"code":"invalid_format","path":"manifestPath","message":"must be an absolute local filesystem path"}, {"code":"invalid_format","path":"sourceMapPath","message":"must be an absolute local filesystem path"}]}export_web_scriptsmanifest plus its map). The change touches input advertisement and boundary rejection only, and the accepted-value path is unchanged:runstill forwards the same three values under the same domain keys.For boundary fixes, identify the applicable boundary regressions and lifecycle regressions covered by the evidence above, and explain relevant gaps. This is an input-contract boundary; no lifecycle stage is involved.
Validation performed
npm run compile— succeeded, produceddist.node scripts/run-typescript.mjs --noEmit— no diagnostics.node scripts/ci/static-check-report.mjs lint— 6626 files, 0 errors, 3332 warnings (all pre-existing categories).node node_modules/vitest/vitest.mjs run tests/boundary/cli/cliInputSchemaRequired.test.ts— 24 passed, including the new case.node scripts/run-typescript.mjs --noEmitandnode scripts/ci/static-check-report.mjs lintwere re-run after strengthening the NUL cases — no diagnostics, 6626 files with 0 errors.src/cli/webSourceLocationCommands.tsreverted — the new case fails, confirming the regression is pinned.node scripts/rea.mjs trace-web-source-location --schema --json— output shown above.node scripts/rea.mjs trace-web-source-location manifest.json 0 map.json http://x 1 0 --json—VALIDATION_ERRORnamingmanifestPathandsourceMapPath.npm run test:focused -- tests/boundary/cli/cliInputSchemaRequired.test.ts— could not run in my checkout:node_modules/.package-lock.jsonis missing after an interruptednpm ci. I ran the same file directly with vitest, as recorded above.Compatibility, safety, and release
--source-map-urlwas already rejected by the domainmin(1), so no previously successful invocation changes outcome.Author readiness
Human owner: @Shelden-Hao
Before merge
type(scope): outcome.