-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Error message regression in Cargo 1.80 when fetching particular git revision #14621
Comments
This is a difference in the failure behavior for fetching a commit that does not exist from a git repository. In the previous behavior, Cargo was less specific to git about the refs it needed fetched, so the failure occurred later. The difference is the
vs
Cargo attempts to fetch the minimal amount of additional data from git. In this case, Cargo is able to be specific about which commits it needs fetched. Since those commits don't exist, git fails. I believe the behavior change in this case was likely introduced by this PR: #13946 The old error message is possibly slightly better but is largely equivalent. Changes in error message are generally not covered by stability guarantees. The new error message does contain the similar level of detail further up in the output from git:
To restore the previous behavior, Cargo would have to parse the output of git, and then generate a fake As Cargo migrates to using |
The message looks worse without
compare to
|
Good point, the message in the non-git-CLI case is far worse (and makes pointless retries). |
It's also interesting to note that leaving the last digit off the one-line repro actually gives a better error message with 1.80.1. Actual repro:
Leave off the last digit of the revision (which I did by accident at one point):
|
This is expected btw, because Cargo check if the rev is a full commit hash. |
I can't really tell which message is worse. In 1.79 it'll fetch everything. If there are 100 tags, they will be shown all at once. In 1.80, the message “not our ref xxx” is a bit unclear comparing to “revspec 'xxx' not found”, which I am fine with it. The worse part is fetching with libgit2 (#14621 (comment)). This needs a fix. Perhaps we can check if Cargo has gone through GitHub fast path (this match arm in particular), we add an error context telling that “rev xxxxx not found on github.com/name/repo” |
Hi , I am kind of new to open source I would like to help , can you please guide me . |
Sure. When fixing a bug in Cargo, we usually write a test first that demonstrates the current buggy behavior, and passes the test suite, followed by other commits fixing both the behavior and the test. This pattern assures that the first commit contains a minimal reproduction. See this contribution guideline for more. In Cargo we don't want any test to acces public network. However, for this issue specifically, since it tests against GitHub fast path, which requires to talk to Cargo, so we need this The fix in my mind needs to tweak the
There might be more stuff I am not aware of. Feel free to ask questions here, on Zulip, or come to our office hours. |
well, hi I hope I am not bothering you, well I am undergrad student and don't have much experience with big project like this and most of the code goes above my head , but I want to help and learn , I would appreciate if you could give me some direction on how to get started , like first few steps |
@BLANKatGITHUB Not sure what skills you have now. The first thing to do is following the steps here to compile Cargo from source. Would highly recommend reading "Cargo Contributor Guide". If you need more helps than that, ping me on Zulip or attend our office hours. |
### What does this PR try to resolve? Fixes Issue : #14621 Adds more error context for fetching a commit that doesn't exists. ### How should we test and review this PR? I've created two tests, one for fast_path and one for libgit2. r? @weihanglo
Problem
I am working on Dependabot support for Rust. Currently Dependabot includes Rust 1.79. I was testing with Rust 1.80 and discovered that a Dependabot unit test started failing.
The specific failing Dependabot unit test exercises fetching a nonexistent revision from a git dependency: https://github.com/dependabot/dependabot-core/blob/main/cargo/spec/dependabot/cargo/update_checker/version_resolver_spec.rb#L355
I created a minimal repro with a .zip file below.
With Cargo 1.79, the final reported error from git is:
revspec '11111b376b93484341c68fbca3ca110ae5cd2708' not found; class=Reference (4); code=NotFound (-3)
With Cargo 1.80, the final reported error becomes:
process didn't exit successfully: ``git fetch --verbose --force --update-head-ok 'https://github.com/BurntSushi/utf8-ranges' '+11111b376b93484341c68fbca3ca110ae5cd2708:refs/commit/11111b376b93484341c68fbca3ca110ae5cd2708'`` (exit status: 128)
This updated error message doesn't describe the nature of the error as usefully as the preceding error, and can't be matched by Dependabot's error message parsing.
Evidently error message fidelity is not necessarily a Cargo goal in all cases, so if this is considered not to be a bug, I will work on a change to make Dependabot able to tolerate the new behavior. But it definitely is a regression from a user perspective to lose clarity on the actual git-level problem.
This was discovered on Linux (where Dependabot runs) but my most recent testing was on Windows; same behavior.
Steps
cargo update -p time:0.1.39 -vv
Expected outcome (with 1.79):
Actual outcome (with 1.80.1):
This more minimal repro by @arlosi also works:
cargo install --git "https://github.com/BurntSushi/utf8-ranges" --rev 11111b376b93484341c68fbca3ca110ae5cd2708
Possible Solution(s)
The new 1.80 output does include this line, which was not previously present:
It looks likely that Dependabot can be updated to look for this error text instead, which may be the simplest solution if this is deemed a won't-fix.
Notes
No response
Version
C:\dev\dbot_git_locked_ref_unit_test_break>cargo version --verbose
cargo 1.80.1
release: 1.80.1
host: x86_64-pc-windows-msvc
libgit2: 1.7.2 (sys:0.18.3 vendored)
libcurl: 8.6.0-DEV (sys:0.4.72+curl-8.6.0 vendored ssl:Schannel)
os: Windows 10.0.22631 (Windows 11 Enterprise) [64-bit]
The text was updated successfully, but these errors were encountered: