diff options
author | jade <lix@jade.fyi> | 2024-06-24 22:49:17 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@localhost> | 2024-06-24 22:49:17 +0000 |
commit | 3e151d4d77b5296b9da8c3ad209932d1dfa44c68 (patch) | |
tree | f5a047e858509a26594acb7cfd6b0f944509a2c4 /tests/functional | |
parent | 35eec921af1043fc6322edc0ad88c872d41623b8 (diff) |
Revert "libfetchers: make attribute / URL query handling consistent"
This reverts commit 35eec921af1043fc6322edc0ad88c872d41623b8.
Reason for revert: Regressed nix-eval-jobs, and it appears to be this change is buggy/missing a case. It just needs another pass.
Code causing the problem in n-e-j, when invoked with `nix-eval-jobs --flake '.#hydraJobs'`:
```
n-e-j/tests/assets ยป ../../build/src/nix-eval-jobs --meta --workers 1 --flake .#hydraJobs
warning: unknown setting 'trusted-users'
warning: `--gc-roots-dir' not specified
error: unsupported Git input attribute 'dir'
error: worker error: error: unsupported Git input attribute 'dir'
```
```
nix::Value *vRoot = [&]() {
if (args.flake) {
auto [flakeRef, fragment, outputSpec] =
nix::parseFlakeRefWithFragmentAndExtendedOutputsSpec(
args.releaseExpr, nix::absPath("."));
nix::InstallableFlake flake{
{}, state, std::move(flakeRef), fragment, outputSpec,
{}, {}, args.lockFlags};
return flake.toValue(*state).first;
} else {
return releaseExprTopLevelValue(*state, autoArgs, args);
}
}();
```
Inspecting the program behaviour reveals that `dir` was in fact set in the URL going into the fetcher. This is in turn because unlike in the case changed in this commit, it was not erased before handing it to libfetchers, which is probably just a mistake.
```
(rr) up
3 0x00007ffff60262ae in nix::fetchers::Input::fromURL (url=..., requireTree=requireTree@entry=true) at src/libfetchers/fetchers.cc:39
warning: Source file is more recent than executable.
39 auto res = inputScheme->inputFromURL(url, requireTree);
(rr) p url
$1 = (const nix::ParsedURL &) @0x7fffdc874190: {url = "git+file:///home/jade/lix/nix-eval-jobs",
base = "git+file:///home/jade/lix/nix-eval-jobs", scheme = "git+file", authority = std::optional<std::string> = {[contained value] = ""},
path = "/home/jade/lix/nix-eval-jobs", query = std::map with 1 element = {["dir"] = "tests/assets"}, fragment = ""}
(rr) up
4 0x00007ffff789d904 in nix::parseFlakeRefWithFragment (url=".#hydraJobs", baseDir=std::optional<std::string> = {...},
allowMissing=allowMissing@entry=false, isFlake=isFlake@entry=true) at src/libexpr/flake/flakeref.cc:179
warning: Source file is more recent than executable.
179 FlakeRef(Input::fromURL(parsedURL, isFlake), getOr(parsedURL.query, "dir", "")),
(rr) p parsedURL
$2 = {url = "git+file:///home/jade/lix/nix-eval-jobs", base = "git+file:///home/jade/lix/nix-eval-jobs", scheme = "git+file",
authority = std::optional<std::string> = {[contained value] = ""}, path = "/home/jade/lix/nix-eval-jobs", query = std::map with 1 element = {
["dir"] = "tests/assets"}, fragment = ""}
(rr) list
174
175 if (pathExists(flakeRoot + "/.git/shallow"))
176 parsedURL.query.insert_or_assign("shallow", "1");
177
178 return std::make_pair(
179 FlakeRef(Input::fromURL(parsedURL, isFlake), getOr(parsedURL.query, "dir", "")),
180 fragment);
181 }
```
Change-Id: Ib55a882eaeb3e59228857761dc1e3b2e366b0f5e
Diffstat (limited to 'tests/functional')
-rw-r--r-- | tests/functional/fetchers.sh | 91 | ||||
-rw-r--r-- | tests/functional/meson.build | 1 |
2 files changed, 0 insertions, 92 deletions
diff --git a/tests/functional/fetchers.sh b/tests/functional/fetchers.sh deleted file mode 100644 index 0f888dc33..000000000 --- a/tests/functional/fetchers.sh +++ /dev/null @@ -1,91 +0,0 @@ -source common.sh - -requireGit - -clearStore - -testFetchTreeError() { - rawFetchTreeArg="${1?fetchTree arg missing}" - messageSubstring="${2?messageSubstring missing}" - - output="$(nix eval --impure --raw --expr "(builtins.fetchTree $rawFetchTreeArg).outPath" 2>&1)" && status=0 || status=$? - grepQuiet "$messageSubstring" <<<"$output" - test "$status" -ne 0 -} - -# github/gitlab/sourcehut fetcher input validation -for provider in github gitlab sourcehut; do - # ref/rev validation - testFetchTreeError \ - "{ type = \"$provider\"; owner = \"foo\"; repo = \"bar\"; ref = \",\"; }" \ - "URL '$provider:foo/bar' contains an invalid branch/tag name" - - testFetchTreeError \ - "\"$provider://host/foo/bar/,\"" \ - "URL '$provider:foo/bar', ',' is not a commit hash or a branch/tag name" - - testFetchTreeError \ - "\"$provider://host/foo/bar/f16d8f43dd0998cdb315a2cccf2e4d10027e7ca4?rev=abc\"" \ - "URL '$provider://host/foo/bar/f16d8f43dd0998cdb315a2cccf2e4d10027e7ca4?rev=abc' already contains a ref or rev" - - testFetchTreeError \ - "\"$provider://host/foo/bar/ref?ref=ref2\"" \ - "URL '$provider://host/foo/bar/ref?ref=ref2' already contains a ref or rev" - - # host validation - testFetchTreeError \ - "{ type = \"$provider\"; owner = \"foo\"; repo = \"bar\"; host = \"git_hub.com\"; }" \ - "URL '$provider:foo/bar' contains an invalid instance host" - - testFetchTreeError \ - "\"$provider://host/foo/bar/ref?host=git_hub.com\"" \ - "URL '$provider:foo/bar' contains an invalid instance host" - - # invalid attributes - testFetchTreeError \ - "{ type = \"$provider\"; owner = \"foo\"; repo = \"bar\"; wrong = true; }" \ - "unsupported input attribute 'wrong'" - - testFetchTreeError \ - "\"$provider://host/foo/bar/ref?wrong=1\"" \ - "unsupported input attribute 'wrong'" -done - -# unsupported attributes w/ tarball fetcher -testFetchTreeError \ - "\"https://host/foo?wrong=1\"" \ - "unsupported tarball input attribute 'wrong'. If you wanted to fetch a tarball with a query parameter, please use '{ type = \"tarball\"; url = \"...\"; }" - -# test for unsupported attributes / validation in git fetcher -testFetchTreeError \ - "\"git+https://github.com/owner/repo?invalid=1\"" \ - "unsupported Git input attribute 'invalid'" - -testFetchTreeError \ - "\"git+https://github.com/owner/repo?url=foo\"" \ - "URL 'git+https://github.com/owner/repo?url=foo' must not override url via query param!" - -testFetchTreeError \ - "\"git+https://github.com/owner/repo?ref=foo.lock\"" \ - "invalid Git branch/tag name 'foo.lock'" - -testFetchTreeError \ - "{ type = \"git\"; url =\"https://github.com/owner/repo\"; ref = \"foo.lock\"; }" \ - "invalid Git branch/tag name 'foo.lock'" - -# same for mercurial -testFetchTreeError \ - "\"hg+https://forge.tld/owner/repo?invalid=1\"" \ - "unsupported Mercurial input attribute 'invalid'" - -testFetchTreeError \ - "{ type = \"hg\"; url = \"https://forge.tld/owner/repo\"; invalid = 1; }" \ - "unsupported Mercurial input attribute 'invalid'" - -testFetchTreeError \ - "\"hg+https://forge.tld/owner/repo?ref=,\"" \ - "invalid Mercurial branch/tag name ','" - -testFetchTreeError \ - "{ type = \"hg\"; url = \"https://forge.tld/owner/repo\"; ref = \",\"; }" \ - "invalid Mercurial branch/tag name ','" diff --git a/tests/functional/meson.build b/tests/functional/meson.build index d99f9bbd3..a13dee001 100644 --- a/tests/functional/meson.build +++ b/tests/functional/meson.build @@ -93,7 +93,6 @@ functional_tests_scripts = [ 'fetchGitRefs.sh', 'gc-runtime.sh', 'tarball.sh', - 'fetchers.sh', 'fetchGit.sh', 'fetchurl.sh', 'fetchPath.sh', |