-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Incorrect parsing of version into url hostname #4625
Comments
That is pretty strange. Those requests should all be coming from When did you first see this issue for this repo? We have been rolling out some changes to the |
I first noticed them this morning, but I haven't been watching the dependabot runs closely, as most of our repos are suffering from #4536. Here's another Job ID with similar failure but a different failing dep: 254513777 Agreed that it is weird. If I get time, I'll try to see if I can repro this locally, but that may not happen for a bit. |
I see this same error has occurred back in Dec 16, 2021 so that would rule out the |
I dug into this a little more... dependabot-core/go_modules/lib/dependabot/go_modules/file_updater/go_mod_updater.rb Line 174 in c4f3e6e
That is correctly caught as a repo resolvability error and ends up here: dependabot-core/go_modules/lib/dependabot/go_modules/file_updater/go_mod_updater.rb Lines 243 to 246 in c4f3e6e
But then things go sideways, because this line grabs the wrong repo URL:
Look again at the error message above... it's giving the name of the repo that we are running dependabot against, which is located on GitHub. But then the subdependency which is actually causing the error is not on github. The regex is looking for the last url that contains "github", so it grabs the wrong url. At that point, the code starts working as expected... it throws a So there's four variants here:
Unfortunately, while looking at the code, it looks like case 2/4 are not handled properly within the url splitting of dependabot-core/go_modules/lib/dependabot/go_modules/resolvability_errors.rb Lines 18 to 23 in c4f3e6e
For example, if I modify the original error message so that both URLs point at github:
results in a So there's a few things going on here... The nice part is that once the three new test cases are added, it should be easy to repro/validate fixes. |
Ah, nice find! The purpose of that code is to raise |
I was trying to create a test project for this, and noticed the following little nuance... this error only shows up when the go mod cache is empty:
So the fix will probably be to catch / strip that |
Actually, thinking about this more... as a user, it's helpful to know which direct dep is triggering the failing indirect dep. That may not be possible with the current code structure, and it's not a deal breaker if so because they can use other |
When `go get -d github.com/org/repo@v1.2.3` starts with an empty module cache, it appears to prepend an additional status string (copied from dependabot#4625 (comment)): # first run throws full error - note that repo2 is a direct dependency of repo1 [dependabot-core-dev] ~/dependabot-core/tmp/<redacted-org>/repo1 $ GOPRIVATE=* go get -d github.com/<redacted-org>/repo2@v0.39.0 go: downloading github.com/<redacted-org>/repo2 v0.39.0 go get: reading google.golang.org/grpc/go.mod at revision v1.33.0: unknown revision # second run doesn't include the `go: downloading...` line [dependabot-core-dev] ~/dependabot-core/tmp/<redacted-org>/repo1 $ GOPRIVATE=* go get -d github.com/<redacted-org>/repo2@v0.39.0 go get: reading google.golang.org/grpc/go.mod at revision v1.33.0: unknown revision v1.33.0 # clean the modcache [dependabot-core-dev] ~/dependabot-core/tmp/<redacted-org>/repo1 $ go clean -modcache # the full error shows up again [dependabot-core-dev] ~/dependabot-core/tmp/<redacted-org>/repo1 $ GOPRIVATE=* go get -d github.com/<redacted-org>/repo2@v0.39.0 go: downloading github.com/<redacted-org>/repo2 v0.39.0 go get: reading google.golang.org/grpc/go.mod at revision v1.33.0: unknown revision It's currently unclear if this is only thrown on `unknown revision` errors, or any generic error that happens from a clean module cache. I suspect the latter, but haven't yet taken the time to dive into the `go get` source. Most likely this will be fixed by stripping out the status line very early in the error handling pipeline, and then passing along the normal error. But the first step is getting a working test case to repro the error... this PR is currently a WIP at doing that, and then will be gradually updated to actually fix the issue. Note that I don't know much Ruby, let alone Rspec, so once I hack together a semi-workable solution this will definitely need some further polish from actual Rubyists before being ready for merge. Fix dependabot#4625
…rror When `go get github.com/org/repo@v1.2.3` starts with an empty module cache, it appears to prepend an additional status string (copied from dependabot#4625 (comment)): # first run throws full error - note that repo2 is a direct dependency of repo1 [dependabot-core-dev] ~/dependabot-core/tmp/<redacted-org>/repo1 $ GOPRIVATE=* go get -d github.com/<redacted-org>/repo2@v0.39.0 go: downloading github.com/<redacted-org>/repo2 v0.39.0 go get: reading google.golang.org/grpc/go.mod at revision v1.33.0: unknown revision # second run doesn't include the `go: downloading...` line [dependabot-core-dev] ~/dependabot-core/tmp/<redacted-org>/repo1 $ GOPRIVATE=* go get -d github.com/<redacted-org>/repo2@v0.39.0 go get: reading google.golang.org/grpc/go.mod at revision v1.33.0: unknown revision v1.33.0 # clean the modcache [dependabot-core-dev] ~/dependabot-core/tmp/<redacted-org>/repo1 $ go clean -modcache # the full error shows up again [dependabot-core-dev] ~/dependabot-core/tmp/<redacted-org>/repo1 $ GOPRIVATE=* go get -d github.com/<redacted-org>/repo2@v0.39.0 go: downloading github.com/<redacted-org>/repo2 v0.39.0 go get: reading google.golang.org/grpc/go.mod at revision v1.33.0: unknown revision This `go: downloading abc` line causes the entire multi-line string to match the regex for unknown revision: ``` go: .*: unknown revision ``` However, it doesn't match the single line that we care about: ``` go get: reading google.golang.org/grpc/go.mod at revision v1.33.0: unknown revision ``` So within `filter_error_message()`, the entire multi-line string is returned, even though the first line is a simple status message, and we only care about the second line: https://github.com/dependabot/dependabot-core/blob/bc6162c1ae44c431ae2f394dccd270a762da6af8/go_modules/lib/dependabot/go_modules/file_updater/go_mod_updater.rb#L266-L272 Because the entire line matches the regex, it's still correctly caught as a repo resolvability error and ends up here: https://github.com/dependabot/dependabot-core/blob/c4f3e6eae592c5c42332719b9e597c8bd47a2db9/go_modules/lib/dependabot/go_modules/file_updater/go_mod_updater.rb#L243-L246 But then things go sideways, because this line grabs the wrong repo URL: https://github.com/dependabot/dependabot-core/blob/c4f3e6eae592c5c42332719b9e597c8bd47a2db9/go_modules/lib/dependabot/go_modules/resolvability_errors.rb#L9 And from there it eventually manifests as the inscrutable error: ``` updater | INFO <job_254312325> Handled error whilst updating github.com/company/redactedrepo: git_dependencies_not_reachable {:"dependency-urls"=>["github.com/company/redactedrepo v0.50.0\ngo get"]} ``` While there's a number of additional defensive checks that can be added later on in the process, ultimately the root problem is that the regex simply needs to check for `go get:`, not just `go:`. Even more confusingly, this problem seems to have disappeared with `go` `1.18`. When I dug into the logs, it's because the `go get:` line now reports itself as `go:`, so the original regex now matches. But we've seen this `get` come and go... for example `go` `1.18` actually added it back for something else: dependabot#4868 I don't actually know if the root cause is racy output within the `go get` tooling (ie, intermittently appears in all versions), or if refactoring from one `go` version to the next changes which section of code outputs the status messages. So in summary, we should add a non-capturing group to handle if/when the `get` ever re-appears. Fix dependabot#4625
Fixed by #4910 Defensive to prevent similar bugs: #4911 Defensive to emit the error message sooner in the pipeline if something is amiss: #4913 That should take care of everything I commented on here... My original take that the |
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).
Saw a weird error about cannot reach the URL for a particular repo. Digging further, I found the following in the log:
Looks to me like the version number was extracted and then for some reason it was used as the hostname?
I took a quick look at git history of the go modules code, and nothing changed recently. Maybe something changed in a lower layer of general URL parsing within dependabot?
The text was updated successfully, but these errors were encountered: