Skip to content
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

Add defensive checks to prevent inscrutable error messages #4913

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jeffwidman
Copy link
Member

Part of the reason
#4625 was so
difficult to debug was the original error messages were a total red
herring. They appeared to be related to IPs, but digging deeper realized
they were actually due to errors happening earlier in the processing
pipeline but not caught until several steps down the line.

So this adds some defensive checks so that if there's an upstream error,
we catch it sooner and report the proper error message(s).

# How to implement this though?
# * Ruby has no built-in URL parsing, and no great alternatives in https://stackoverflow.com/q/1805761/770425...
# Not sure what Dependabot team policy is on using 3rd-party gems?
# Alternatively a basic sanity check of "it should not contain whitespace" may suffice for now... ??
Copy link
Member Author

Choose a reason for hiding this comment

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

@jurre @mctofu any feedback on implementing this? Maybe there's a gem that's already being used elsewhere in another check that could be leveraged here? Otherwise, given that this is a simple defensive check, a regex match on any whitespace (especially spaces and newlines) is probably sufficient.

Copy link
Contributor

Choose a reason for hiding this comment

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

Do we expect a URL here or just the module path? If it's the path we could use some of the basic character checks from https://pkg.go.dev/golang.org/x/mod/module#CheckImportPath / https://pkg.go.dev/golang.org/x/mod/module#CheckPath as a start? Agree we just need a simple defensive check rather than a robust validation here.

# TODO: currently this matches last. Instead, if more than one match, and they
# aren't identical, then don't try to be clever with GitDependenciesNotReachable
# but instead raise DependencyFileNotResolvable and report the whole error.
# This would have resulted in a more obvious error message for #4625
Copy link
Member Author

@jeffwidman jeffwidman Mar 26, 2022

Choose a reason for hiding this comment

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

I actually wasn't 100% sure on this... I could see a case where a multi-line error string may have multiple URLs, and the last one is indeed the proper one to match on...

But given that GitDependenciesNotReachable tells the user that Dependabot can't reach the repo and to update their access creds, that's a fairly opinionated solution...

IMO I'd only want to report that if 110% sure that's the issue, otherwise surface the whole error message and let the user diagnose the issue.

(I assume DependencyFileNotResolvable reports the message to the end user... if it just hides it in logs that only Dependabot devs can see, then that's not so helpful either.)

Copy link
Contributor

Choose a reason for hiding this comment

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

I see these cases as most useful to raise GitDependenciesNotReachable.

  1. You have a direct dependency on a private github repo but Dependabot doesn't have access to it.
  2. You have an indirect dependency on a github private repo (from another direct private github dependency) but Dependabot doesn't have access to it.

Do we have examples of what multiple URLs look like in this error message handy? I imagine this could get tricky if you had a failing indirect dependency on another host that came from one of your direct github dependencies.

@jeffwidman jeffwidman force-pushed the add-defensive-checks-to-prevent-inscrutable-error-messages branch from 139aaaf to c762fc2 Compare April 25, 2023 06:56
@github-actions github-actions bot added the L: go:modules Golang modules label Apr 25, 2023
Part of the reason
dependabot#4625 was so
difficult to debug was the original error messages were a total red
herring. They appeared to be related to IPs, but digging deeper realized
they were actually due to errors happening earlier in the processing
pipeline but not caught until several steps down the line.

So this adds some defensive checks so that if there's an upstream error,
we catch it sooner and report the proper error message(s).
@jeffwidman jeffwidman force-pushed the add-defensive-checks-to-prevent-inscrutable-error-messages branch from c762fc2 to 74f3942 Compare December 16, 2023 01:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
L: go:modules Golang modules
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants