-
Notifications
You must be signed in to change notification settings - Fork 74
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
refactor: exit on invalid slug #823
refactor: exit on invalid slug #823
Conversation
If slug is missing a forward slash, or "undefined", log error and exit
Codecov Report
@@ Coverage Diff @@
## main #823 +/- ##
==========================================
+ Coverage 92.09% 92.13% +0.04%
==========================================
Files 33 34 +1
Lines 1164 1170 +6
Branches 237 238 +1
==========================================
+ Hits 1072 1078 +6
- Misses 61 62 +1
+ Partials 31 30 -1
Flags with carried forward coverage won't be shown. Click here to find out more.
|
export function checkSlug(slug: string | undefined): boolean { | ||
if (slug !== '' && !slug?.match(/\//)) { | ||
return false | ||
} | ||
return true | ||
} |
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.
A future PR should move this function to validate.ts.
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.
No action is required for this annotation.
@@ -0,0 +1,6 @@ | |||
export function checkSlug(slug: string | undefined): boolean { | |||
if (slug !== '' && !slug?.match(/\//)) { |
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.
This line was extracted from where it existed previously:
Line 328 in 12dccfc
if (buildParams.slug !== '' && !buildParams.slug?.match(/\//)) { |
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.
No action is required for this annotation.
Co-authored-by: Mitchell Borrego <mitchell@codecov.io>
This pull request introduces 1 alert when merging 629db8b into 9f1f09b - view on LGTM.com new alerts:
|
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.
fix: remove unused import
This pull request introduces 1 alert when merging 5d78f42 into 6e53069 - view on LGTM.com new alerts:
|
logError(`Slug must follow the format of "<owner>/<repo>" or be blank. We detected "${buildParams.slug}"`) | ||
const validSlug = checkSlug(buildParams.slug) | ||
if (!validSlug) { | ||
throw new Error(`Slug must follow the format of "<owner>/<repo>" or be blank. We detected "${buildParams.slug}"`) |
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.
Question on this....
I use token authentication to upload codecov reports (using --token
flag) and because the slug (using the -r
flag) is not being passed through due to the token being present (source), this line is now throwing, and failing my builds to upload the reports to codecov. Is there a way to fix this?
More context: I am using Google Cloud Build, which I noticed is not one of the providers, not sure if that helps.
Logs:
<truncated>
[2022-08-22T17:43:39.633Z] ['info'] Using manual override from args.
[2022-08-22T17:43:39.636Z] ['error'] Error detecting repos setting using git: Error: Unable to detect provider.
[2022-08-22T17:43:39.637Z] ['verbose'] Using the following upload parameters:
[2022-08-22T17:43:39.637Z] ['verbose'] commit
[2022-08-22T17:43:39.637Z] ['verbose'] name
[2022-08-22T17:43:39.637Z] ['verbose'] tag
[2022-08-22T17:43:39.637Z] ['verbose'] flags
[2022-08-22T17:43:39.637Z] ['verbose'] parent
[2022-08-22T17:43:39.637Z] ['error'] There was an error running the uploader: Slug must follow the format of "<owner>/<repo>" or be blank. We detected "undefined"
[2022-08-22T17:43:39.638Z] ['verbose'] The error stack is: Error: Slug must follow the format of "<owner>/<repo>" or be blank. We detected "undefined"
at main (/snapshot/repo/dist/src/index.js)
[2022-08-22T17:43:39.638Z] ['verbose'] End of uploader: 278 milliseconds
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 the excellent investigation, @sorliem. You gave very relevant information and it provided me with a huge head-start on fixing this issue.
slug
should not be being validated if a token is passed in.
I created #859 from your comment to track this issue. It should be fixed once #857 is merged.
With regards to Google Cloud Build, I opened #858 to track the feature request.
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 @mitchell-codecov !
If slug is missing a forward slash, or "undefined", log error and exit