fix(preprod): Fix project slug/id confusion in a few places#107491
fix(preprod): Fix project slug/id confusion in a few places#107491
Conversation
static/app/views/preprod/buildComparison/main/sizeCompareSelectedBuilds.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/preprod/buildComparison/main/sizeCompareSelectedBuilds.tsx
Show resolved
Hide resolved
2130abe to
d3715fb
Compare
d3715fb to
a0f5714
Compare
| interface BuildLinkParams { | ||
| organizationSlug: string; | ||
| projectId: string; | ||
| projectId: number | string; |
There was a problem hiding this comment.
Bit confused by this change, won't it make it more confusing to get the id vs slug right? 😆
a0f5714 to
c6b2a6f
Compare
| icon={<IconSettings />} | ||
| aria-label={t('Settings')} | ||
| to={`/settings/${organization.slug}/projects/${project?.slug}/mobile-builds/`} | ||
| to={`/settings/${organization.slug}/projects/${project.slug}/mobile-builds/`} |
There was a problem hiding this comment.
Bug: The component incorrectly uses ProjectsStore.getById() with a project slug, causing project to be undefined. The removal of optional chaining from project.slug will cause a crash.
Severity: CRITICAL
Suggested Fix
In buildDetailsHeaderContent.tsx, change the project lookup to use the correct method for a slug. Replace const project = ProjectsStore.getById(projectId); with const project = ProjectsStore.getBySlug(projectId); to ensure the project is found correctly.
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/preprod/buildDetails/header/buildDetailsHeaderContent.tsx#L206
Potential issue: In `buildDetailsHeaderContent.tsx`, the `project` object is fetched
using `ProjectsStore.getById(projectId)`. However, the `projectId` prop it receives from
the parent component (`buildDetails.tsx`) is actually a project slug string from the
URL, not a numeric ID. This causes the `getById` lookup to fail, making the `project`
variable `undefined`. The removal of optional chaining in the new code at line 206 means
that the attempt to access `project.slug` will result in a `TypeError`, causing the
application to crash when rendering the build details page.
No description provided.