Skip to content

Include the original error in NuGet.Config failure messages - #7843

Merged
Nigusu-Allehu merged 1 commit into
NuGet:devfrom
AsadIqbal-Dev:dev-asadiqbal-config-error-message
Nov 4, 2026
Merged

Nigusu-Allehu merged 1 commit into
NuGet:devfrom
AsadIqbal-Dev:dev-asadiqbal-config-error-message

Conversation

@AsadIqbal-Dev

@AsadIqbal-Dev AsadIqbal-Dev commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Bug

Fixes: NuGet/Home#12651

Description

SettingsFile.ExecuteSynchronized already passes e.Message to its four error strings, but the strings only use {0}, so the original error never shows up. For a broken config you only get NuGet.Config is not valid XML. Path: '...'., with no line number or reason.

I added Reason: {1} to ShowError_ConfigInvalidOperation, ShowError_ConfigInvalidXml, ShowError_ConfigUnauthorizedAccess and Unknown_Config_Exception, the same wording ShowError_ConfigHasInvalidPackageSource uses, with a comment for translators. No code changes were needed.

UpdateXlf resets these four translations to state="new" because a placeholder was added, so they show in English until they're translated again. The build doesn't regenerate Resources.Designer.cs, so I updated its doc comments by hand.

Tests: I updated the assertions that matched the old message exactly:

  • SettingsFile_Constructor_WithMalformedConfig_Throws and SettingsFile_Constructor_InvalidXml_Throws
  • SavePackageSources_ThrowWhenConfigReadOnly
  • Resolve_WhenNuGetConfigUnreadable_ReturnsFailedSdkResultAndLogsError

They fail on dev with the new assertions.

On net10.0, NuGet.Configuration.Test: 672 passed, 6 skipped. Microsoft.Build.NuGetSdkResolver.Test: 64 passed.

PR Checklist

  • Meaningful title, helpful description and a linked NuGet/Home issue
  • Added tests
  • Link to an issue or pull request to update docs if this PR changes settings, environment variables, new feature, etc.

@AsadIqbal-Dev
AsadIqbal-Dev requested a review from a team as a code owner November 2, 2026 17:24
@dotnet-policy-service dotnet-policy-service Bot added the Community PRs created by someone not in the NuGet team label Nov 2, 2026
@Nigusu-Allehu
Nigusu-Allehu merged commit a9a50e7 into NuGet:dev Nov 4, 2026
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Community PRs created by someone not in the NuGet team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

I/O exception reading NuGet.config does not log the original exception message

4 participants