fix(arg-parsing): allow project display names with spaces in org/project argument#1116
fix(arg-parsing): allow project display names with spaces in org/project argument#1116sentry[bot] wants to merge 1 commit into
Conversation
|
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit b7d99fb. Configure here.
| isDisplayName && parsed.org !== undefined | ||
| ? foundOrgs.filter((o) => o.slug === parsed.org) | ||
| : foundOrgs; | ||
|
|
There was a problem hiding this comment.
Issue list ignores display names
High Severity
Parsing now emits project-search with originalSlug for org/<display name>, but resolveTargetsFromParsedArg still only calls findProjectsBySlug and slug-pattern fallbacks. It never uses display-name triage, so sentry issue list (and similar list commands) keep failing after the parse fix.
Reviewed by Cursor Bugbot for commit b7d99fb. Configure here.
| const orgs = | ||
| isDisplayName && parsed.org !== undefined | ||
| ? foundOrgs.filter((o) => o.slug === parsed.org) | ||
| : foundOrgs; |
There was a problem hiding this comment.
Org scope ignored in fuzzy search
Medium Severity
project-search now carries optional org for org/<display name>, and only resolveOrgProjectTarget filters organizations before fuzzy matching. resolveProjectBySlug, handleProjectSearch, and similar paths still search all accessible orgs, so an explicit org prefix may resolve to the wrong project.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit b7d99fb. Configure here.
| const { projects, orgs: foundOrgs } = isDisplayName | ||
| ? { projects: [], orgs: await listOrganizations() } | ||
| : await findProjectsBySlug(parsed.projectSlug); | ||
|
|
There was a problem hiding this comment.
Bug: The resolveTargetsFromParsedArg function doesn't handle project display names (e.g., "My Project") when an organization is specified, causing commands like sentry issue list to fail.
Severity: MEDIUM
Suggested Fix
The logic for handling display names from resolveOrgProjectTarget should be mirrored in the project-search case within resolveTargetsFromParsedArg. Specifically, it should check if the project identifier is a display name and, if so, skip the findProjectsBySlug call and proceed directly to the fuzzy matching logic, ensuring the search is correctly scoped to the provided organization.
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: src/lib/resolve-target.ts#L1643-L1646
Potential issue: The `resolveTargetsFromParsedArg` function, used by commands like
`sentry issue list`, does not correctly handle project searches that use a display name
containing spaces (e.g., `sentry/"My Project"`). The code enters the `project-search`
case and calls `findProjectsBySlug` with the display name, which is not a valid slug and
causes the search to fail. The logic to handle display names by skipping
`findProjectsBySlug` and performing fuzzy matching was implemented in
`resolveOrgProjectTarget` but was missed in `resolveTargetsFromParsedArg`, leading to
inconsistent behavior and command failure for this use case.
Did we get this right? 👍 / 👎 to inform future reviews.


This PR addresses CLI-1RA, where
sentry issue list(and other commands usingparseOrgProjectArg) would throw aValidationErrorwhen a project display name containing spaces was provided in theorg/projectargument format (e.g.,sentry/My Project).The root cause was an inconsistency in
src/lib/arg-parsing.ts. While bare project slugs (My Project) and leading-slash project slugs (/My Project) correctly fell back to a fuzzy display-name search when spaces were detected, the explicitorg/projectpath inparseSlashOrgProjectdirectly calledvalidateResourceId, which strictly rejects spaces.This fix aligns the behavior across all input forms:
src/lib/arg-parsing.ts: InparseSlashOrgProject, if the project segment of anorg/projectargument contains spaces (i.e.,looksLikeDisplayNameis true), it now returns aproject-searchtype, preserving the provided organization slug.src/lib/arg-parsing.ts: TheParsedOrgProjecttype'sproject-searchvariant was updated to include an optionalorgfield to carry this context.src/lib/resolve-target.ts: InresolveOrgProjectTarget, the display-name based project search (isDisplayNamepath) now filters the list of organizations to search within if anorgis provided in theproject-searchobject, ensuring the search remains scoped to the user's explicit organization.Fixes CLI-1RA