Skip to content

ref: Use getApiURl() inside of static/app/views/settings/*#107392

Merged
ryan953 merged 6 commits intomasterfrom
ryan953/ref-getApiUrl-app-setting
Feb 3, 2026
Merged

ref: Use getApiURl() inside of static/app/views/settings/*#107392
ryan953 merged 6 commits intomasterfrom
ryan953/ref-getApiUrl-app-setting

Conversation

@ryan953
Copy link
Member

@ryan953 ryan953 commented Jan 31, 2026

@ryan953 ryan953 requested review from a team as code owners January 31, 2026 19:51
@github-actions github-actions bot added the Scope: Frontend Automatically applied to PRs that change frontend components label Jan 31, 2026
Copy link
Contributor

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.

Copy link
Member

@gggritso gggritso left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool! I think that one complaint for Bugbot is legitimate but not blocking 👍🏻

@ryan953
Copy link
Member Author

ryan953 commented Feb 2, 2026

Cool! I think that one complaint for Bugbot is legitimate but not blocking 👍🏻

cursor was right! i think i put this in a few other places in the other PRs.

edit: found one other spot and fixed it.

Comment on lines +93 to 103
{
path: {
organizationIdOrSlug: organization.slug,
configId: codeMappingId!,
},
}
),
],
{staleTime: Infinity, enabled: Boolean(codeMappingId)}
);

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: The useApiQuery key calls getApiUrl with a potentially null codeMappingId, creating an invalid API URL like .../code-mappings/null/codeowners/ on initial render.
Severity: MEDIUM

Suggested Fix

Conditionally define the query key to be null or an empty array when codeMappingId is falsy. This prevents getApiUrl from being called with an invalid parameter. For example: const queryKey = codeMappingId ? [getApiUrl(...)] : []; useApiQuery(queryKey, ...).

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:
static/app/views/settings/project/projectOwnership/addCodeOwnerModal.tsx#L87-L103

Potential issue: In `addCodeOwnerModal.tsx`, the `useApiQuery` hook's query key is
evaluated on every render, even when the query is disabled. The key is constructed using
`getApiUrl` with `codeMappingId!`. When `codeMappingId` is `null` or `undefined` (e.g.,
on initial modal render), the non-null assertion `!` bypasses TypeScript checks. The
`getApiUrl` function then receives `null` and converts it to the literal string "null"
using `String(null)`. This results in an invalid API request being made to a URL like
`/.../code-mappings/null/codeowners/`, which will fail with a 404 error.

Did we get this right? 👍 / 👎 to inform future reviews.

@ryan953 ryan953 merged commit 3528478 into master Feb 3, 2026
69 of 71 checks passed
@ryan953 ryan953 deleted the ryan953/ref-getApiUrl-app-setting branch February 3, 2026 20:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Frontend Automatically applied to PRs that change frontend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants