Conversation
Issue search treats project as a slug, so agents that paste project:<id> hit a 400 (CLI-FA). Same auto-repair path as OR→in-list: rewrite digits to project_id, leave slugs and namespaced keys alone. Co-authored-by: Cursor <cursoragent@cursor.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
1 Skipped Deployment
|
4 tasks
## Summary Follow-up to #1621. `sanitizeQuery` warned `Running query:` after the numeric `project:` rewrite, then again after OR/AND. Combined input logged an intermediate that never ran. All rewrites now finish first. One warning: reasons on the first line, `Running query:` on the second, quoting the query that is actually sent. Same for a failed OR: no `Running query:` before the `ValidationError`. Stacked on #1621 — merge that first. ### Before / after ```bash sentry issue list --json -q "project:123 OR project:456" ``` **Before** — two warnings, first one is a lie: ```text ⚠ `project` is the slug; numeric ids use project_id. Rewrote numeric project: filters. Running query: "project_id:123 OR project_id:456" ⚠ Rewrote OR using in-list syntax: key:[val1,val2]. Running query: "project_id:[123,456]" ``` **After** — one warning, final query on its own line: ```text ⚠ `project` is the slug; numeric ids use project_id. Rewrote numeric project: filters. Rewrote OR using in-list syntax: key:[val1,val2]. Running query: "project_id:[123,456]" ``` ## Test plan - [ ] `project:123 OR project:456` → `project_id:[123,456]`, one warn, `Running query:` on the second line - [ ] `project:123 AND is:unresolved` → `project_id:123 is:unresolved`, same shape - [ ] `level:error OR assigned:me` throws with no `Running query:` - [ ] From `packages/cli`: `pnpm exec vitest run test/lib/search-query.test.ts test/lib/search-query.warn.test.ts` --------- Co-authored-by: Cursor <cursoragent@cursor.com>
Comment on lines
445
to
452
| notes.push("Rewrote OR using in-list syntax: key:[val1,val2]."); | ||
| if (hasAnd) { | ||
| notes.push("Also removed explicit AND (implicit in Sentry search)."); | ||
| } | ||
| notes.push(`Running query: "${result}"`); | ||
| log.warn(notes.join(" ")); | ||
| return result; | ||
| return serializeNodes(rewritten); | ||
| } | ||
|
|
||
| throw new ValidationError( |
Contributor
There was a problem hiding this comment.
Bug: If a query with a numeric project filter fails to parse, it's rewritten and returned silently without the intended warning, because the warning logic is skipped.
Severity: MEDIUM
Suggested Fix
Move the logic for detecting and noting rewrites to before the try...catch block for parsing. This ensures that any modification to the query is recorded and warned about, even if the subsequent parsing step fails. The warning can then be emitted regardless of the parse outcome.
Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.
Location: packages/cli/src/lib/search-query.ts#L445-L452
Potential issue: In the `sanitizeQuery` function, if a search query contains a numeric
project filter like `project:123` and also has a syntax error that causes the PEG parser
to fail (e.g., an unmatched parenthesis), the query is modified by
`rewriteNumericProjectFilters`. However, because the `parse` function throws an
exception, the `catch` block returns the rewritten query directly. This control flow
bypasses the `preParseRewriteNotes` function call, which is responsible for generating a
warning about the modification. As a result, the user's query is silently changed, which
contradicts the intended behavior of warning users about automatic rewrites.
This branch was successfully deployed
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
Issue search treats
projectas a slug. Agents paste Sentry's numeric project id into--queryand get a 400 (CLI-FA).project_idis the numeric field.sanitizeQuerynow rewritesproject:<digits>and all-numericproject:[id,id]toproject_id, with a warning, same as the existing OR → in-list repair. Slugs (project:frontend), already-correctproject_id:…, namespaced keys (bolt.project_id), quoted strings, and mixed in-lists are left alone.Before / after
Command from CLI-FA:
sentry issue list --json -q "project:4511730126487632 environment:vercel-production"Before — 400,
ApiError, grouped in CLI-FA. The API rejects a numeric value on the slug field:After — rewrite in
sanitizeQuery, warn, run the query, exit 0:Stdout is the issue list JSON. Same rewrite for
project:[4505521413357568,6442225]→project_id:[…].Test plan
sanitizeQuery("project:4511730126487632 environment:vercel-production")→project_id:4511730126487632 environment:vercel-productionproject:[4505521413357568,6442225]rewrites;project:[frontend,6442225]does notproject:frontend,project_id:123,bolt.project_id:70054175,message:"project:123"unchangedpackages/cli:pnpm exec vitest run test/lib/search-query.test.ts test/lib/search-query.property.test.ts