-
Couldn't load subscription status.
- Fork 410
Wrap API configuration errors when setting up CodeQL #3217
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR enhances error handling for API configuration errors by updating the HTTP error detection mechanism and extending error handling coverage to the CodeQL setup logic. The main improvement is replacing the simple isHTTPError type check with a more robust asHTTPError function that can handle different HTTP error formats.
Key Changes
- Replaced
isHTTPErrorboolean function withasHTTPErrorconverter function that normalizes HTTP errors - Extended API configuration error wrapping to handle rate limiting (429 status) as configuration errors
- Updated CodeQL setup logic to use the improved error handling wrapper
Reviewed Changes
Copilot reviewed 16 out of 16 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/util.ts | Replaced isHTTPError with asHTTPError function to handle both status and httpStatusCode properties |
| src/api-client.ts | Enhanced wrapApiConfigurationError to handle 429 rate limit errors and use new HTTP error detection |
| src/codeql.ts | Updated CodeQL setup to use API configuration error wrapping and removed specific RequestError handling |
| src/upload-lib.ts | Updated to use new asHTTPError function for consistent error handling |
| src/trap-caching.ts | Updated import and usage to use new HTTP error detection method |
| src/status-report.ts | Updated import and usage to use new HTTP error detection method |
| src/feature-flags.ts | Updated to use new HTTP error detection method |
| lib/*.js | Generated JavaScript files reflecting the TypeScript changes |
src/api-client.ts
Outdated
| httpError.message.includes("API rate limit exceeded") || | ||
| httpError.message.includes("commit not found") || | ||
| httpError.message.includes("Resource not accessible by integration") || | ||
| /ref .* not found in this repository/.test(httpError.message) |
Copilot
AI
Oct 20, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] The error message check has been made more generic by removing 'for installation', but this could potentially match unintended error messages. Consider using a more specific pattern or combining with status code checks for better accuracy.
| httpError.message.includes("API rate limit exceeded") || | |
| httpError.message.includes("commit not found") || | |
| httpError.message.includes("Resource not accessible by integration") || | |
| /ref .* not found in this repository/.test(httpError.message) | |
| ((httpError.message.includes("API rate limit exceeded") && | |
| (httpError.status === 403 || httpError.status === 429)) || | |
| httpError.message.includes("commit not found") || | |
| httpError.message.includes("Resource not accessible by integration") || | |
| /ref .* not found in this repository/.test(httpError.message)) |
| } catch (rawError) { | ||
| const e = api.wrapApiConfigurationError(rawError); | ||
| const ErrorClass = | ||
| e instanceof util.ConfigurationError || |
Copilot
AI
Oct 20, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] The removal of the RequestError status 429 check from the ErrorClass condition logic appears intentional since this is now handled by wrapApiConfigurationError, but the comment should be updated to reflect that rate limiting is now handled upstream.
| e instanceof util.ConfigurationError || | |
| e instanceof util.ConfigurationError || | |
| // Rate limiting (HTTP 429) is now handled upstream by wrapApiConfigurationError. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Just a couple of small suggestions I thought of while reviewing.
a0c5447 to
e6e649a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for implementing those suggestions, and even making the checks in asHTTPError more thorough than suggested!
Update generic API configuration error handling to handle HTTP errors with the
httpStatusCodeproperty instead of thestatusCodeproperty, and update the CodeQL setup logic to use this error handling.Risk assessment
For internal use only. Please select the risk level of this change:
Which use cases does this change impact?
analysis-kinds: code-scanning).analysis-kinds: code-quality).upload-sarif).How did/will you validate this change?
.test.tsfiles).pr-checks).If something goes wrong after this change is released, what are the mitigation and rollback strategies?
How will you know if something goes wrong after this change is released?
Merge / deployment checklist