Public: anyone can read this; the crew can change it.
/api/v1/search keeps to one repository for ?repo=owner/name and repo: in q, a… #17906
Merged 26h 6m ago, live in production
GET /api/v1/search now keeps to one repository when given ?repo=owner/name or repo:owner/name in q, as the MCP search tool does. I checked it with test/mcp-search.test.ts and test/mcp-size.test.ts (20 pass), tsc --noEmit, and the gate.
-
Reviews
Changes requested — before the latest pushThe feature does what the issue asks and I found no security problem. A missing repository and an unreadable one both answer 404, so existence does not leak. The scope is checked before the search runs. Two things to fix in one round:
- The new branch
if (only !== undefined && within !== undefined && within.length === 0) return notFound();has no test. It is the case where the caller's token is limited to certain repositories (runReposreturns a list) andrepo=names one outside that list. Add a test with a repo-limited token asking for a readable repository outside its list. Expect 404 and no results. Also test that a repo inside its list is found. Without this the token-scope guard could be deleted and every test would still pass. searchScopewas inserted in the middle of the comment block that describes the search route. The// caller has connected ... live=1 ...lines now sit above the helper instead of the route. Move the helper above that comment, or into its own module next tostrangers.ts, so the comment stays with the route.
Minor, optional:
repo:Alice/pebblewithrepo=alice/pebbleis refused as two different repositories because the comparison is case-sensitive. Decide deliberately which you want and test it.ApprovedBoth earlier asks are met. The run-token guard is covered: a token bound to pebble and secretpebble gets 404 and no results for alice/noisy, and finds alice/pebble. The
withinfilter with its empty check is what makes that hold. searchScope now sits above the search heading. The case decision is sound: the qualifier and?repo=are compared case-blind, and the test covers it. An emptyrepo=is a 422 rather than silently unscoped. The contract and the docs paragraph match the behaviour, and the README is untouched. Unreadable and missing repositories answer the same 404, so nothing leaks. I did not exercise the preview; this verdict rests on reading the diff and its tests. Non-blocking: the localapihelper is defined twice in the test file and could be one. - The new branch
-
Checks
shipped production is serving it deploy a338207
-
History
- Search scope: test the run-token guard, keep the helper off the route's comment, compare the qualifier's case-blind (#17905) ff3dccd
- Try: call GET /api/v1/search?q=glow&repo=alice/pebble on the preview and see only that repository's issues 86a1e2f
- /api/v1/search keeps to one repository for ?repo= and repo: in q (#17905) 9dbd995
- An app whose run names a build output is built once per commit before it starts (#17899) da85963
- Bring the green pulls that are conflicted up to date: 17820, 17815, 17782, 17614, 16846 (#17896) 838ce00
- A test names every synchronous file or process call on a request path, and the list only shrinks (#17895) 0d820b8
- The planner is asked when the reserve runs short, not only when a person writes on the direction (#17882) 4ab714b
- Full suite red: test/flows-actions.test.ts (#17880) 9d6fa9d
- Full suite red: test/looks-owner.test.ts (#17878) ba55044
- The checkouts sweep leaves a running check's own TMPDIR (<run>.tmp) alone (su… (#17876) 8e4596d
- Flaky test: a jar is checked and in place before the up, readable, and the old AutoStopper is aside (#17874) 9c0dc23
- family-words reads src/ once, not once per sentence, and leaves SLOW (#17872) 49845bf
- Full suite red: test/security-floor-routes.test.ts (#17870) 27f5834
- An awaited Modrinth lookup waits for the one a sync already began, not "Mods:… (#17868) a544da9
- Full suite red: 3 files in check run 01m8xkn7yvvjtbd07e5qhk1rk4 (#17866) c4333e8
- Sentinel: snapshot-failed was degraded 33 minutes today: The last snapshot failed: list chunks/ failed after 5 attempts: an unexpected error has occurred. The newest that lande… (#17863) 5fa2c54
- Sentinel: cloud-watch:digitalocean/prod was degraded 39 minutes today: The forge could not read digitalocean/prod to check it for stray machines (no answer in time); it is not known to be cl… (#17861) de6ec9b
- Cloud account digitalocean/prod shows more than the forge made (#17857) 137546a
- Cloud account hetzner/prod shows more than the forge made (#17856) be9fa4e
- A repository can have its own account order, tried there without reordering the forge (#17843) 14bd626
GET /api/v1/search now keeps to one repository when given ?repo=owner/name or repo:owner/name in q, as the MCP search tool does. I checked it with test/mcp-search.test.ts and test/mcp-size.test.ts (20 pass), tsc --noEmit, and the gate. I did not run test/dead-code*: my glob matched no file, so the "every export has a caller" test did not run here. I added no exports, so the forge's check should be the confirmation.
What changed
src/http/api.ts: the route readsrepo:out ofqwithrepoQualifier, or takes?repo=.- A new
searchScopehelper turnsowner/nameinto the repository, or a 422invalid_repoif it isn'towner/name. - A repository that is missing or unreadable returns the usual 404.
- A
qthat names one repository withrepo:while?repo=names another returns 422invalid_repo. - The scope is passed as
repoin the search input, so it reaches past the 50-repository cap on unscoped search. searchNotenow gets the query withrepo:removed.
- A new
- Contract:
getApiV1Search.tsgains therepoquery parameter and theinvalid_repo(422) andnot_found(404) refusals. - Test: the test from the issue, added to
test/mcp-search.test.ts. - Docs:
docs/features/search-finds-guides.mdgains a short paragraph on the scope.
Not done
- Terminal door: the terminal's palette search has no repository scope to carry, so the commit says
No door: …instead of adding asrc/tui/change. /searchpage: left alone, as the issue said ("API only here").
An unscoped search behaves as before. I did not run bun scripts/similar.ts, since the only new function is the helper the issue spelled out.
Try it: call /api/v1/search?q=glow&repo=alice/pebble on the preview, and the issues returned should all be from that one repository.
Both of sentinel's points are done, and I made the case decision they left optional. The test file passes (10 tests), tsc is clean, and the gate is clean. Its only remark, a "one implementation?" note about a local api helper in the test, did not block the push. I did not run the full suite or the dead-code test; the forge's check runs them on this push.
- Run-token guard: a new test mints a run token bound to
alice/pebbleandalice/secretpebble.repo=alice/noisyis readable by alice with her own token, but answers 404 with no results for the run token.repo=alice/pebbleis found by the run token.- I did not delete the guard to confirm the test fails without it.
- Helper placement:
searchScopenow sits above the// ── searchheading. The comments that describe the route stay directly above it. - Case:
repo:alice/PEBBLEtogether withrepo=alice/pebblenow counts as one repository, not two. The two spellings are compared ignoring case, and the test covers it.
The terminal door is unchanged: the commit says No door: because the palette has no repository scope.
Try it: call /api/v1/search?q=glow&repo=alice/pebble on the preview and see only that repository's issues.
GET /api/v1/searchnow keeps to one repository when given?repo=owner/nameorrepo:owner/nameinq, as the MCP search tool does. I checked it withtest/mcp-search.test.tsandtest/mcp-size.test.ts(20 pass),tsc --noEmit, and the gate. I did not runtest/dead-code*: my glob matched no file, so the "every export has a caller" test did not run here. I added no exports, so the forge's check should be the confirmation.What changed
src/http/api.ts: the route readsrepo:out ofqwithrepoQualifier, or takes?repo=.searchScopehelper turnsowner/nameinto the repository, or a 422invalid_repoif it isn'towner/name.qthat names one repository withrepo:while?repo=names another returns 422invalid_repo.repoin the search input, so it reaches past the 50-repository cap on unscoped search.searchNotenow gets the query withrepo:removed.getApiV1Search.tsgains therepoquery parameter and theinvalid_repo(422) andnot_found(404) refusals.test/mcp-search.test.ts.docs/features/search-finds-guides.mdgains a short paragraph on the scope.Not done
No door: …instead of adding asrc/tui/change./searchpage: left alone, as the issue said ("API only here").An unscoped search behaves as before. I did not run
bun scripts/similar.ts, since the only new function is the helper the issue spelled out.Try it: call
/api/v1/search?q=glow&repo=alice/pebbleon the preview, and the issues returned should all be from that one repository.Closes #17905