-
Notifications
You must be signed in to change notification settings - Fork 458
fix(parser): wrap upstream errors with %w in import pipeline #46414
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
Changes from all commits
bdd578b
16a641d
cf5a132
c9a688e
558cbe0
df63989
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| package parser | ||
|
|
||
| // pathRelError is returned when filepath.Rel fails during a security path check. | ||
| // Its Error() method omits the internal absolute paths from the filepath.Rel | ||
| // diagnostic so they do not leak into user-facing error messages, while Unwrap() | ||
| // preserves the upstream error for errors.Is / errors.As traversal. | ||
| type pathRelError struct { | ||
| msg string | ||
| err error | ||
| } | ||
|
|
||
| func (e *pathRelError) Error() string { return e.msg } | ||
| func (e *pathRelError) Unwrap() error { return e.err } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -228,7 +228,10 @@ func (p *ScheduleParser) minimumIntervalTokenCount(hasWeekdaysSuffix bool) int { | |
| func (p *ScheduleParser) parseLongIntervalParts() (int, string, error) { | ||
| intervalStr := p.tokens[1] | ||
| interval, err := strconv.Atoi(intervalStr) | ||
| if err != nil || interval < 1 { | ||
| if err != nil { | ||
| return 0, "", fmt.Errorf("invalid interval '%s', must be a positive integer: %w", intervalStr, err) | ||
| } | ||
| if interval < 1 { | ||
| return 0, "", fmt.Errorf("invalid interval '%s', must be a positive integer", intervalStr) | ||
|
Comment on lines
+231
to
235
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Addressed in c9a688e. Added |
||
| } | ||
|
|
||
|
|
||
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.
Addressed in c9a688e. Added
TestParseGitHubURL_NumErrorWrappinginpkg/parser/github_urls_test.gowith four table-driven cases covering numbered URLs (PR, issue), run URL, and job URL, each assertingerrors.As(err, &(*strconv.NumError)(nil))is reachable.