Skip to content

Conversation

@github-actions github-actions bot added the Scope: Frontend Automatically applied to PRs that change frontend components label Sep 16, 2025
integratedOrgId: integratedOrgId!,
repository: repository!,
});
}}
Copy link
Contributor

Choose a reason for hiding this comment

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

Bug: Null Assertion Error in API URL Construction

The useRepo hook and regenerateToken mutation use non-null assertions on integratedOrgId and repository from usePreventContext. These values can be undefined or null during initial render or before user selection, which results in malformed API URLs (e.g., /owner/undefined/repository/undefined/) and can cause API errors or runtime issues.

Additional Locations (3)

Fix in Cursor Fix in Web

Comment on lines +92 to +94
integratedOrgId: integratedOrgId!,
repository: repository!,
});
Copy link
Contributor

Choose a reason for hiding this comment

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

Potential bug: The non-null assertion operator (!) is used on optional context fields integratedOrgId and repository, which can be undefined, causing a runtime error.
  • Description: The context fields integratedOrgId and repository are defined as optional in PreventContextData. However, they are used with the non-null assertion operator (!) in addUploadTokenStep.tsx when calling the regenerateToken mutation, and also in onboarding.tsx within the useRepo hook. The logic in the context provider can result in these fields being undefined, for instance, when a user navigates directly to the page without URL parameters or existing localStorage state. This will cause an immediate JavaScript TypeError when the component renders or the mutation is called, leading to a runtime crash.

  • Suggested fix: Before using integratedOrgId and repository, add a check to ensure they are defined. If they are not, you could show a loading state, an error message, or disable the functionality that depends on them until the values are available. Avoid using the non-null assertion operator without this validation.
    severity: 0.8, confidence: 0.95

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

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.

1 participant