NixOS / nix

Nix, the purely functional package manager
https://nixos.org/
GNU Lesser General Public License v2.1
12.86k stars 1.52k forks source link

GET parameters are deleted from flake input url paths #11920

Open ivan-tkatchev opened 2 days ago

ivan-tkatchev commented 2 days ago

Describe the bug

        /* The URL query parameters serve two roles: specifying fetch
           settings for Nix itself, and arbitrary data as part of the
           HTTP request. Now that we've processed the Nix-specific
           attributes above, remove them so we don't also send them as
           part of the HTTP request. */
        for (auto & param : allowedAttrs())
            url.query.erase(param);

        input.attrs.insert_or_assign("type", std::string { schemeName() });
        input.attrs.insert_or_assign("url", url.to_string());
    StringSet allowedAttrs() const override
    {
        return {
            "type",
            "url",
            "narHash",
            "name",
            "unpack",
            "rev",
            "revCount",
            "lastModified",
        };
    }

If a flake url has name or type as parameters, then they will be silently removed from the url.

"name" and "type" are extremely common names for parameters and aren't Nix-specific, silently removing them is a big usability bug.

ivan-tkatchev commented 2 days ago

Counterintuitively, specifying a flake like this, with a "type" = "file" attrset key turns off the GET parameter removal logic.

    important-key = {
      url = "https://example.com/export?type=whatever";
      type = "file";
      flake = false;
    };