[repo-assist] Fix credential lookup for www.nuget.org / nuget.org mismatch (fixes #3843) - #4418
Merged
dsyme merged 1 commit intoSep 1, 2026
Conversation
Closes #3843 The documented `paket config add-token 'https://www.nuget.org' <token>` example stores the token under the www.nuget.org source, but `paket push` (with no --url) looks up credentials using the default URL https://nuget.org (no www). ConfigFile.getSourceNodes only did an exact string match (after trimming trailing slashes), so the stored token was never found, causing push to fall through to a missing/invalid API key error. This normalizes the www. prefix for source comparisons only (does not change the actual URL used for requests), so tokens/credentials stored for https://www.nuget.org are found when looking up https://nuget.org and vice versa. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🤖 This PR was created by Repo Assist, an automated AI assistant.
Closes #3843
Root cause
paket config add-token 'https://www.nuget.org' <token>(the exact example shown in docs/content/commands/config.md) stores the token under the sourcehttps://www.nuget.org.paket pushwithout an explicit--urllooks up credentials using the default sourcehttps://nuget.org(nowww) — seePublicAPI.fs(Dependencies.Push).ConfigFile.getSourceNodesonly matched sources with an exact string comparison (after trimming a trailing slash), so a token stored underhttps://www.nuget.orgwas never found when looking uphttps://nuget.org. Push then fell through to requiring an explicit API key and failed with a confusing 403 error, exactly matching the symptom reported in #3843.Fix
getSourceNodesnow also normalizes away awww.host prefix when comparing the storedsourceattribute to the requested source, sohttps://nuget.organdhttps://www.nuget.org(and(redacted) variants) are treated as equivalent for credential lookup purposes only. The actual URL used for requests is unchanged — this only affects the config-file source-matching logic insrc/Paket.Core/Versioning/ConfigFile.fs`.Trade-offs
www.prefix normalization (not nuget.org-specific), matching the existing trailing-slash normalization already present ingetSourceNodes. It's scoped to the credential source-matching comparison only, so it can't change what host/URL is actually contacted.NetUtils.normalizeFeedUrl(used for package-source/feed matching), but that function's scope and equivalence list is feed-specific; a minimal, localwww.normalization directly inConfigFile.fsis more surgical and keeps the change isolated to the credential-lookup path.Test Status
dotnet build src/Paket.Core/Paket.Core.fsproj -f netstandard2.0— succeeded (0 errors, pre-existing warnings only).dotnet test tests/Paket.Tests/Paket.Tests.fsproj -f net10.0 --filter "FullyQualifiedName~ConfigFileSpecs|FullyQualifiedName~RemotePushUrl"— 12 passed, 0 failed, 2 skipped (skipped tests are pre-existing Windows-only crypto tests, not related to this change).get source nodes ignores www prefix mismatch for nuget.orgintests/Paket.Tests/Versioning/ConfigFileSpecs.fsthat verifies a token stored forhttps://www.nuget.orgis found viahttps://nuget.organd vice versa.Add this agentic workflow to your repo
To install this agentic workflow, run