ref: Use getApiURl() inside of static/app/views/settings/*#107392
ref: Use getApiURl() inside of static/app/views/settings/*#107392
getApiURl() inside of static/app/views/settings/*#107392Conversation
static/app/views/settings/account/accountSecurity/accountSecurityEnroll.tsx
Show resolved
Hide resolved
There was a problem hiding this comment.
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.
static/app/views/settings/organizationIntegrations/integrationReposAddRepository.tsx
Outdated
Show resolved
Hide resolved
gggritso
left a comment
There was a problem hiding this comment.
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. |
| { | ||
| path: { | ||
| organizationIdOrSlug: organization.slug, | ||
| configId: codeMappingId!, | ||
| }, | ||
| } | ||
| ), | ||
| ], | ||
| {staleTime: Infinity, enabled: Boolean(codeMappingId)} | ||
| ); | ||
|
|
There was a problem hiding this comment.
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.
See: https://gist.github.com/ryan953/af5458fa4f89ae42cc19e8ea266b7e9a