| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
There was a problem hiding this comment.
This PR addresses missing telemetry coverage by wrapping initialization code in try/catch blocks across multiple action entry points. Previously, if errors occurred during early initialization (before the try/catch), they would not be captured in telemetry.
Changes:
Copilot reviewed 10 out of 10 changed files in this pull request and generated no comments.
Show a summary per file| File | Description |
|---|---|
| src/upload-sarif-action.ts | Moved initializeEnvironment, version checks, and starting status report inside try/catch |
| src/start-proxy-action.ts | Moved persistInputs inside try/catch |
| src/setup-codeql-action.ts | Moved initializeEnvironment, API details creation, and job UUID generation inside try/catch |
| src/init-action.ts | Moved initializeEnvironment, persistInputs, and early initialization inside try/catch; changed variable declarations to let for proper scoping |
| src/analyze-action.ts | Moved initializeEnvironment and persistInputs inside try/catch |
Sorry, something went wrong.
There was a problem hiding this comment.
Thank you for putting this together! This generally looks good. I have done some checking here to verify that the exceptions we get from the functions that are now in the try/catch blocks are of the types we'd want (see also my comment there).
Two higher-level questions:
Sorry, something went wrong.
| auth: getRequiredInput("token"), | ||
| externalRepoAuth: getOptionalInput("external-repository-token"), | ||
| url: getRequiredEnvParam("GITHUB_SERVER_URL"), | ||
| apiURL: getRequiredEnvParam("GITHUB_API_URL"), |
There was a problem hiding this comment.
getRequiredInput throws a ConfigurationError when the input is not supplied. That makes sense.
getRequiredEnvParam throws an Error rather than a ConfigurationError. We'd probably always expect these environment variables to be available, and if they're not it's probably nothing a user can do anything about, so Error probably makes sense for that.
Worth thinking about in general though, whether we want one or the other for a given input/env variable.
Observation: since this was previously outside the try/catch block, we also didn't get telemetry for failures here before.
Sorry, something went wrong.
There was a problem hiding this comment.
I'd be surprised if these environment variables weren't set within the Actions environment, but agreed in general.
Sorry, something went wrong.
It's defensive, but I'd rather not just rely on the comments. Implemented. |
Sorry, something went wrong.
There was a problem hiding this comment.
Thank you for adding the extra error handling, and also spotting that one function call that wasn't in a try/catch block yet!
I spotted a few things that we should think about -- see the individual comments.
Sorry, something went wrong.
| } | ||
| } catch (e) { | ||
| logger.warning( | ||
| `Caught an exception while sending the error status report: ${e}.`, |
There was a problem hiding this comment.
Few points here:
Sorry, something went wrong.
There was a problem hiding this comment.
Sorry, something went wrong.
| await sendUnexpectedErrorStatusReport( | ||
| ActionName.StartProxy, | ||
| startedAt, | ||
| error, |
There was a problem hiding this comment.
For start-proxy, we deliberately don't include the error to avoid leaking any sensitive information in the main handler in the (now) run function. We should probably omit the error here too.
Sorry, something went wrong.
There was a problem hiding this comment.
This looks good now, thanks! Just one question and a couple of very minor points.
Sorry, something went wrong.
| } else if (isInTestMode()) { | ||
| throw new Error( | ||
| "Failed to create status report for unhandled error in test mode.", | ||
| ); |
There was a problem hiding this comment.
Intuitively this is unnecessary, because createStatusReportBase throws if isInTestMode() is true, so we should never have the statusReport === undefined case there.
Did you add this deliberately to catch a potential scenario where createStatusReportBase doesn't throw in test mode, but statusReport is undefined anyway?
Sorry, something went wrong.
There was a problem hiding this comment.
Did you add this deliberately to catch a potential scenario where createStatusReportBase doesn't throw in test mode, but statusReport is undefined anyway?
Yes, but this is probably overly defensive. I'll remove it.
Sorry, something went wrong.
| } | ||
| } catch (e) { | ||
| logger.warning( | ||
| `Failed to send the error status report: ${getErrorMessage(e)}.`, |
There was a problem hiding this comment.
Minor: Perhaps add "unhandled" before "error status report", so it's more obvious what this log message relates to.
Sorry, something went wrong.
There was a problem hiding this comment.
I'd originally held off since this is customer facing, but it's probably not confusing in retrospect.
Sorry, something went wrong.
| logger, | ||
| undefined, | ||
| getErrorMessage(error), | ||
| `Unhandled error: ${getErrorMessage(error)}`, |
There was a problem hiding this comment.
Minor: Maybe change this to "Unhandled CodeQL Action error" or "Unhandled ${actionName} error" so it's a less generic prefix / less likely to clash with some error message we might get from elsewhere.
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
The start of some of the Actions' entrypoints was not covered by a try/catch statement, resulting in missed telemetry if any of the code there errored.
Address it by pulling almost all the code into a try/catch statement for each of the Actions.
We could potentially also move this try/catch into the wrapper, but it can be useful to include other variables if they are set (like entries from the config) in the error telemetry.
Risk assessment
For internal use only. Please select the risk level of this change:
Which use cases does this change impact?
Workflow types:
Products:
Environments:
How did/will you validate this change?
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?
Are there any special considerations for merging or releasing this change?
Merge / deployment checklist