Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Classify third-party upload SyntaxErrors as configuration errors#2171

Merged
angelapwen merged 3 commits into
github:maingithub/codeql-action:mainfrom
angelapwen:classify-syntax-errorsangelapwen/codeql-action:classify-syntax-errorsCopy head branch name to clipboard
Feb 28, 2024
Merged

Classify third-party upload SyntaxErrors as configuration errors#2171
angelapwen merged 3 commits into
github:maingithub/codeql-action:mainfrom
angelapwen:classify-syntax-errorsangelapwen/codeql-action:classify-syntax-errorsCopy head branch name to clipboard

Conversation

@angelapwen

@angelapwen angelapwen commented Feb 28, 2024

Copy link
Copy Markdown
Contributor

We frequently see SyntaxErrors from the upload action that are currently classified as failures. We were previously catching this error in the countResultsInSarif method, but this method runs after validateSarifFileSchema, which would have thrown a SyntaxError before we're able to throw it as an InvalidRequestError.

This change moves the error catching to validateSarifFileSchema so that we will appropriately classify it as an InvalidRequestError.

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.

@angelapwen angelapwen requested a review from a team as a code owner February 28, 2024 15:25
henrymercer
henrymercer previously approved these changes Feb 28, 2024

@henrymercer henrymercer left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM. As a bonus, we could produce a slightly better error message, e.g. "Could not upload <path> as it is not a valid JSON file."

@angelapwen

Copy link
Copy Markdown
Contributor Author

Ah.. I think we are already attempting to catch this error, but it's not happening in the right place. Let me try to fix.

@angelapwen

Copy link
Copy Markdown
Contributor Author

Ok, I think this should do it with the appropriate error wrapping (see updated PR body)!

Comment thread src/upload-lib.ts Outdated
)}`,
);
}
} catch (e) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nit: this now wraps quite a lot of code, for safety, consider wrapping just the JSON.parse call, or catching just SyntaxErrors.

@angelapwen angelapwen Feb 28, 2024

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

You're right! I changed it to wrap just the JSON.parse 😄

@angelapwen angelapwen force-pushed the classify-syntax-errors branch from 273f564 to 62712e9 Compare February 28, 2024 16:02
@angelapwen angelapwen merged commit 9330c68 into github:main Feb 28, 2024
@angelapwen angelapwen deleted the classify-syntax-errors branch February 28, 2024 16:32
@github-actions github-actions Bot mentioned this pull request Feb 29, 2024
8 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.