Skip to content

fix(search): rewrite numeric project: filters to project_id - #1621

Open
betegon wants to merge 1 commit into
mainfrom
fix/search-numeric-project-id
Open

betegon wants to merge 1 commit into
mainfrom
fix/search-numeric-project-id

Conversation

@betegon

@betegon betegon commented Sep 22, 2026

Copy link
Copy Markdown
Member

Summary

Issue search treats project as a slug. Agents paste Sentry's numeric project id into --query and get a 400 (CLI-FA). project_id is the numeric field.

sanitizeQuery now rewrites project:<digits> and all-numeric project:[id,id] to project_id, with a warning, same as the existing OR → in-list repair. Slugs (project:frontend), already-correct project_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:

Error: Failed to fetch issues from 1 project(s): Failed to list issues: 400 Bad Request
  Endpoint: /api/0/organizations/…/issues/
  Invalid query: …

  Suggestions:
    • Check your --query syntax (Sentry search reference: …)
    • Try a shorter time range: --period 14d or --period 24h
    • Verify you have access to the target project: sentry project list <org>/

After — rewrite in sanitizeQuery, warn, run the query, exit 0:

⚠ `project` is the slug; numeric ids use project_id. Rewrote numeric project: filters. Running query: "project_id:4511730126487632 environment:vercel-production"

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-production
  • project:[4505521413357568,6442225] rewrites; project:[frontend,6442225] does not
  • project:frontend, project_id:123, bolt.project_id:70054175, message:"project:123" unchanged
  • From packages/cli: pnpm exec vitest run test/lib/search-query.test.ts test/lib/search-query.property.test.ts

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>
@vercel

vercel Bot commented Sep 22, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
cli Ready Ready Preview Sep 22, 2026 2:10pm UTC
1 Skipped Deployment
Project Deployment Actions Updated
sentry-local Skipped Skipped Sep 22, 2026 2:10pm UTC

Request Review

@vercel
vercel Bot temporarily deployed to Preview – sentry-local September 22, 2026 14:09 Inactive
@betegon
betegon marked this pull request as ready for review September 22, 2026 14:11
@github-actions github-actions Bot added the risk: medium PR risk score: medium label Sep 22, 2026
Comment thread packages/cli/src/lib/search-query.ts

This branch was successfully deployed

1 active and 1 inactive deployments
Preview – cli 9af240d4 Deployed Sep 22, 2026 by vercel[bot]
Preview – sentry-local 9af240d4 Deployed Sep 22, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk: medium PR risk score: medium

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant