Repository navigation
fix(server): make session list filters exclusive - #56197
rekram1-node wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
The fix works. With this change, the new session-list test passes; against the base it fails, because the server returns 200 for directory+project, for subpath on its own and for directory+subpath. Server and protocol tests and type checks pass. I found no in-repo caller of session.list that sends either combination this now rejects.
One thing to fix: the new field descriptions make the committed packages/protocol/openapi.json stale. bun run check:generated in packages/protocol fails with this change and passes on the base. Please run bun run generate there and commit the result.
Public API: GET /api/session now returns 400 (InvalidRequestError) for directory+project and for subpath without project, where it used to accept them (an inconsistent cursor for the first, an ignored subpath for the second). The OpenAPI query parameters gain descriptions. Other request shapes and the generated clients are unchanged. This breaks only callers that send those combinations: they need to send a single location filter.
| project: Project.ID.pipe(Schema.optional), | ||
| subpath: RelativePath.pipe(Schema.optional), | ||
| cursor: SessionsCursor.pipe(Schema.optional), | ||
| directory: AbsolutePath.pipe(Schema.optional).annotate({ |
There was a problem hiding this comment.
These descriptions change the generated spec, and the committed packages/protocol/openapi.json doesn't include them yet: bun run check:generated in packages/protocol now fails with "Generated OpenAPI document is stale". Running bun run generate there updates the four query parameters (+8/-4).
|
Closing: this added new filter rules rather than expressing existing ones, and isn't needed to expose session.list to plugins. |
Problem
GET /api/sessionacceptsdirectory,project, andsubpathin any combination, but the pagination cursor only carries one location shape: directory, project with an optional subpath, or no location. Encoding the next cursor silently drops whatever does not fit.directory+project: page 1 filters by both;cursor.nextkeeps onlydirectory, so page 2 returns a different set.subpathwithoutproject: accepted, but the store ignores it and the cursor drops it.Change
session.listrejectsdirectory+projectandsubpathwithoutprojectwithInvalidRequestError(400). No in-repo caller sends either combination.workspacefield from the cursor test and cover cursor round trips for each valid location shape.The check lives in the handler rather than in
SessionsQuery: httpapi-codegen requires a flat struct for query schemas and rejects custom checks as unportable. Generated clients are unchanged.Validation
bun test test/session-list.test.ts(server); fails without the handler changebun testinpackages/protocolandpackages/serverbun run generateinpackages/client(no diff)bun run checkAdded by the opencode bot (AI-generated).
Public API: GET /api/session now rejects directory+project and subpath without project with 400 (breaking only for callers sending those combinations)