-
Notifications
You must be signed in to change notification settings - Fork 96
WIP: Decode url-encoded branch and tag names #344
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
WIP: Decode url-encoded branch and tag names #344
Conversation
|
very cool, thanks @rossng ! I'll convert the PR to draft for now, just ping me when you need the review. Alternatively: would it make sense to only support v4? |
|
Thanks for writing this! I used this in my project today and it fixed the v3->v4 issue! Notice CI failing beforehand: https://github.com/chrisguida/smaug/actions/runs/13045323154 But now it passes! https://github.com/chrisguida/smaug/actions/runs/13077563488 |
|
I tried writing a test for this today and it wasn't too easy. The existing test It seems like the test needs to retrieve a git repository over the network to actually test the failure case. A couple of ideas:
Would appreciate any input or ideas. |
|
@rossng sorry, forgot to circle back!
Then don't worry about this too much. Seems like a good improvement so I'd suggest merging it as-is. If this part of the codebase ends up having to be modified heavily in the future again then we can reconsider. |
|
Any updates here? We just hit this branch url encoded issue and this appears likely to fix it. |
|
My PR wasn't quite right, but I don't have time to work on it, unfortunately. |
|
Ok, any details as to what was missing? |
|
I don't remember exactly, but I know I encountered something while trying to write the test for this behaviour. Like I was transforming the name at fundamentally the wrong stage of the process. |
|
I'll have a quick look today and see if I can unblock this; do you guys have 1-2 examples of recent manifests with the new encoding? |
Nice, here's the git revision adding the problematic patch directive that started to fail our build: As you can see below, it fails to build because of the "/" character in one of the the branch name ( $ nix build "git+https://bitbucket.org/amotus/fundamentum-edge-daemon.git?rev=5724cbc79fa4fb993d81419dc7960eb0d4e6ba45"#fundamentum-edge
error: builder for '/nix/store/p341d0x5ilcg94xcir0bv8xnm4apgwsb-fundamentum-edge-daemon-deps-1.8.0.drv' failed with exit code 101;
last 25 log lines:
> [naersk] RUSTFLAGS:
> [naersk] CARGO_BUILD_RUSTFLAGS: -C linker=cc
> [naersk] CARGO_BUILD_RUSTFLAGS (updated): -C linker=cc --remap-path-prefix /nix/store/ly3ym1a0www4ndmrhqp9l1b8cafqp3sx-crates-io-dependencies=/sources --remap-path-prefix /nix/store/wi8gwr3q0ycx13dcl7wb7a5b91q7gndx-git-dependencies=/sources
> Running phase: buildPhase
> cargo build $cargo_release -j "$NIX_BUILD_CORES" --message-format=$cargo_message_format
> Updating git repository `https://bitbucket.org/amotus/fundamentum-sdk-mqtt.git`
> warning: spurious network error (3 tries remaining): failed to resolve address for bitbucket.org: Temporary failure in name resolution; class=Net (12)
> warning: spurious network error (2 tries remaining): failed to resolve address for bitbucket.org: Temporary failure in name resolution; class=Net (12)
> warning: spurious network error (1 tries remaining): failed to resolve address for bitbucket.org: Temporary failure in name resolution; class=Net (12)
> error: failed to load source for dependency `fundamentum-sdk-mqtt`
>
> Caused by:
> Unable to update https://bitbucket.org/amotus/fundamentum-sdk-mqtt.git?branch=jou%2Ffile-transfer-feature#6e3c4935
>
> Caused by:
> failed to clone into: /build/dummy-src/.cargo-home/git/db/fundamentum-sdk-mqtt-ec156483963a0fbb
>
> Caused by:
> network failure seems to have happened
> if a proxy or similar is necessary `net.git-fetch-with-cli` may help here
> https://doc.rust-lang.org/cargo/reference/config.html#netgit-fetch-with-cli
>
> Caused by:
> failed to resolve address for bitbucket.org: Temporary failure in name resolution; class=Net (12)
> [naersk] cargo returned with exit code 101, exiting
For full logs, run:
nix log /nix/store/p341d0x5ilcg94xcir0bv8xnm4apgwsb-fundamentum-edge-daemon-deps-1.8.0.drv
error: 1 dependencies of derivation '/nix/store/q8xr7fjs5w2mdyb8g5n5vd213f3my991-fundamentum-edge-daemon-1.8.0.drv' failed to buildOur current workaround is to pin the problematic entry to a rev (or alternatively not to use the '/' in the branch name): Which now builds fine with this workaround applied: $ nix build "git+https://bitbucket.org/amotus/fundamentum-edge-daemon.git?rev=596c671d279300733c191ce2e5566942682c95ed"#fundamentum-edge
# -> Success |
|
thanks! I think it should be a fairly quick fix but I have to do some overdue maintenance first; hoping to get to this on Monday! |
|
Took me a bit longer than expected to get to this! I've included @rossng 's fix in here and added a test. @jraygauthier can you try it out? |
Problem
The v4 Cargo lockfile format became the default fairly recently, and it includes a change which applies URL encoding to e.g. branch name parameters in Git URLs.
Cargo.lock v3
Cargo.lock v4
naersk downloads these git dependencies to disk and then uses Cargo's source replacement feature to point the build at this directory so it can be built offline. However, the new lockfile format results in
config.tomlentries like this:But these don't get picked up because the URL-encoded
branchproperty no longer matches. Then at build time, Cargo itself attempts to download the crate from (e.g.) GitHub and gets blocked by the Nix sandbox, causing it to fail.Solution
Apply URL decoding to the
branchandtagbefore writing out theconfig.tomlfile. I don't see howrevcould contain an encoded character, but let me know if it should be done there too.Todo