Skip to content
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

caddy: withPlugins better error messages for untagged plugins #368657

Merged
merged 4 commits into from
Dec 29, 2024

Conversation

stepbrobd
Copy link
Member

@stepbrobd stepbrobd commented Dec 27, 2024

Things done

Context:
#358586 (comment)
#358586 (comment)

Continuation of #358586, better error messages for untagged plugins

When using pkgs.caddy.withPlugins, if a plugin is untagged upstream, users usually provide a commit SHA to replace to the tag/version. This will result in installCheckPhase failure as caddy build-info output uses pseudo-version number (e.g. v0.0.0-20170915032832-14c0d48ead0c).

Example error:

$ nom-build --expr 'with import ./. { }; caddy.withPlugins { plugins = [ "github.com/caddy-dns/[email protected]" "github.com/caddy-dns/cloudflare@89f16b99c18e" "github.com/mholt/caddy-webdav@42168ba04c9dc2cd228ab8c453dbab27654e52e6" ]; hash = "sha256-wqXSd1Ep9TVpQi570TTb96LwzNYvWL5EBJXMJfYWCAk="; }'
...
> Running phase: installCheckPhase
> Plugins not found: github.com/caddy-dns/cloudflare@89f16b99c18e
> Plugins not found: github.com/mholt/caddy-webdav@42168ba04c9dc2cd228ab8c453dbab27654e52e6
...

The error output will change to the following:

$ nom-build --expr 'with import ./. { }; caddy.withPlugins { plugins = [ "github.com/caddy-dns/[email protected]" "github.com/caddy-dns/cloudflare@89f16b99c18e" "github.com/mholt/caddy-webdav@42168ba04c9dc2cd228ab8c453dbab27654e52e6" ]; hash = "sha256-wqXSd1Ep9TVpQi570TTb96LwzNYvWL5EBJXMJfYWCAk="; }'
...
> Running phase: installCheckPhase
> Plugin "github.com/caddy-dns/cloudflare" have incorrect tag:
>   specified: "github.com/caddy-dns/cloudflare@89f16b99c18e"
>   got: "github.com/caddy-dns/[email protected]"
> Plugin "github.com/mholt/caddy-webdav" have incorrect tag:
>   specified: "github.com/mholt/caddy-webdav@42168ba04c9dc2cd228ab8c453dbab27654e52e6"
>   got: "github.com/mholt/[email protected]"
...
  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandboxing enabled in nix.conf? (See Nix manual)
    • sandbox = relaxed
    • sandbox = true
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 25.05 Release Notes (or backporting 24.11 and 25.05 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md.

Add a 👍 reaction to pull requests you find important.

@github-actions github-actions bot added 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 8.has: documentation This PR adds or changes documentation 8.has: changelog 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin 10.rebuild-linux: 1-10 labels Dec 27, 2024
@stepbrobd stepbrobd marked this pull request as ready for review December 27, 2024 23:28
echo " specified: \"$base@$specified\""
echo " got: \"$base@$expected\""
done < <($out/bin/caddy build-info)
done
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does not display anything if a plugin is not found at all.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a fall back but I don't think this will ever get triggered unless there's smth wrong with xcaddy

@nixos-discourse
Copy link

This pull request has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/prs-ready-for-review/3032/5021

@thiagokokada thiagokokada merged commit b821685 into NixOS:master Dec 29, 2024
41 of 42 checks passed
lessThan
sort
toShellVar
;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Out of curiosity, is that a best practice? Is it explained somewhere?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Neither. I particularly don't like but it doesn't hurt (as long you're not using with lib).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've seen a few modules (in nixpkgs of course) pull in library functions right after getting arguments like these:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 8.has: changelog 8.has: documentation This PR adds or changes documentation 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin 10.rebuild-linux: 1-10
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants