GeezerVison is showing github.com — Refactor configuration errors by angelapwen · Pull Request #2105 · github/codeql-action
Conversation
angelapwen
commented
Jan 30, 2024
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
As we add more configuration errors to improve our uptime measurements, I thought it would be nice to refactor the existing errors into their own file. I took inspiration from the FeatureConfig Record that we use for feature flags.
Also, I thought it would be nice to consolidate the place we check for configuration errors into codeql.ts, where the actual command invocations happen.
The PR also renames the UserError type to ConfigurationError to standardize on a single term.
Merge / deployment checklist
- Confirm this change is backwards compatible with existing workflows.
- Confirm the readme has been updated if necessary.
- Confirm the changelog has been updated if necessary.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
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.
I really like the direction, I think it makes a lot of sense to consolidate this class of errors and their handling into a single place. I've added a couple of comments/questions...
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
As we add more configuration errors, we can standardize throwing and catching them in the `codeql` file where we actually invoke the commands.
Also, rename to `isCliConfigurationError` for more clarity.
To maintain parity with the previous logic: only 1 of the 2 conditions needs to hold: either the exit codes match, or the error messages match.
And all associated methods/comments that say `user error`
Now that we are always appending the original error, this test needs to be updated.
|
Okay.. the refactoring based off of the feedback took a bit longer/was more complex than expected, but I think I'm happy with the results 😸
- Now, we simply call
wrapCliConfigurationError on any errors thrown from CLI command invocations in codeql.ts. This will return the appropriate Error type (possibly a ConfigurationError, if it matches any of our known CliConfigErrorCategory values, and possibly with an additional error message prepended for additional context to the user).
- There was a dependency cycle so I moved
CommandInvocationError to the same file as the CLI configuration errors and renamed the file cli-errors.ts to cover both.
- We're unconditionally appending the original error to the additional error message now, because I didn't think it was worth adding an extra case where we don't include the original CLI error. I updated the test cases in
codeql.test.ts to accommodate.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
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.
I like the direction, couple of small queries!
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
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.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
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.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
|