From d00b1c4e7ca45ad60859dfde761dc61d0faac372 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 26 Mar 2026 00:43:09 +0000 Subject: [PATCH 1/5] Add exception handling for admin settings read failures Co-authored-by: Trenly <12611259+Trenly@users.noreply.github.com> Agent-Logs-Url: https://github.com/Trenly/winget-cli/sessions/a2b00ade-cc75-4ccf-bb63-6f81ef0e0176 --- src/AppInstallerCommonCore/AdminSettings.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/AppInstallerCommonCore/AdminSettings.cpp b/src/AppInstallerCommonCore/AdminSettings.cpp index 6d2d8634c1..9dea987a34 100644 --- a/src/AppInstallerCommonCore/AdminSettings.cpp +++ b/src/AppInstallerCommonCore/AdminSettings.cpp @@ -180,7 +180,17 @@ namespace AppInstaller::Settings void AdminSettingsInternal::LoadAdminSettings() { - auto stream = m_settingStream.Get(); + std::unique_ptr stream; + try + { + stream = m_settingStream.Get(); + } + catch (const std::exception& e) + { + AICLI_LOG(Core, Error, << "Failed to read admin settings: " << e.what()); + return; + } + if (!stream) { AICLI_LOG(Core, Verbose, << "Admin settings was not found"); From c4341bd32548ef17850c83e846f9cbd64f8ef99f Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 26 Mar 2026 00:45:16 +0000 Subject: [PATCH 2/5] Fix verification data write failure handling in SecureSettingsContainer Co-authored-by: Trenly <12611259+Trenly@users.noreply.github.com> Agent-Logs-Url: https://github.com/Trenly/winget-cli/sessions/a2b00ade-cc75-4ccf-bb63-6f81ef0e0176 --- src/AppInstallerCommonCore/AdminSettings.cpp | 9 +++++++++ src/AppInstallerCommonCore/Settings.cpp | 18 +++++++++++++++--- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/src/AppInstallerCommonCore/AdminSettings.cpp b/src/AppInstallerCommonCore/AdminSettings.cpp index 9dea987a34..9d5f502368 100644 --- a/src/AppInstallerCommonCore/AdminSettings.cpp +++ b/src/AppInstallerCommonCore/AdminSettings.cpp @@ -188,6 +188,13 @@ namespace AppInstaller::Settings catch (const std::exception& e) { AICLI_LOG(Core, Error, << "Failed to read admin settings: " << e.what()); + AICLI_LOG(Core, Info, << "Admin settings will use default values"); + return; + } + catch (...) + { + AICLI_LOG(Core, Error, << "Failed to read admin settings: unknown exception"); + AICLI_LOG(Core, Info, << "Admin settings will use default values"); return; } @@ -233,6 +240,8 @@ namespace AppInstaller::Settings { m_settingValues.DefaultProxy.emplace(std::move(defaultProxy)); } + + AICLI_LOG(Core, Verbose, << "Admin settings loaded successfully. LocalManifestFiles=" << m_settingValues.LocalManifestFiles); } bool AdminSettingsInternal::SaveAdminSettings() diff --git a/src/AppInstallerCommonCore/Settings.cpp b/src/AppInstallerCommonCore/Settings.cpp index 5bd770cc8e..978fa16ac0 100644 --- a/src/AppInstallerCommonCore/Settings.cpp +++ b/src/AppInstallerCommonCore/Settings.cpp @@ -293,14 +293,19 @@ namespace AppInstaller::Settings return result; } - void SetVerificationData(VerificationData data) + bool SetVerificationData(VerificationData data) { YAML::Emitter out; out << YAML::BeginMap; out << YAML::Key << NodeName_Sha256 << YAML::Value << SHA256::ConvertToString(data.Hash); out << YAML::EndMap; - m_secure.Set(out.str()); + bool result = m_secure.Set(out.str()); + if (!result) + { + AICLI_LOG(Core, Warning, << "Failed to write verification data for '" << m_name << "'"); + } + return result; } public: @@ -338,7 +343,14 @@ namespace AppInstaller::Settings VerificationData verData; verData.Hash = m_hash.value(); - SetVerificationData(verData); + if (!SetVerificationData(verData)) + { + AICLI_LOG(Core, Error, << "Failed to set verification data for '" << m_name << "'; reverting write"); + // Verification data write failed, so we need to revert the main write + // to maintain consistency + Remove(); + return false; + } } return exchangeResult; From 8bd3ed348960b0f50316ba5a83ec4dc90073e314 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 26 Mar 2026 00:46:54 +0000 Subject: [PATCH 3/5] Address code review feedback: improve error messages and logging Co-authored-by: Trenly <12611259+Trenly@users.noreply.github.com> Agent-Logs-Url: https://github.com/Trenly/winget-cli/sessions/a2b00ade-cc75-4ccf-bb63-6f81ef0e0176 --- src/AppInstallerCommonCore/AdminSettings.cpp | 4 ++-- src/AppInstallerCommonCore/Settings.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/AppInstallerCommonCore/AdminSettings.cpp b/src/AppInstallerCommonCore/AdminSettings.cpp index 9d5f502368..103d09735f 100644 --- a/src/AppInstallerCommonCore/AdminSettings.cpp +++ b/src/AppInstallerCommonCore/AdminSettings.cpp @@ -193,7 +193,7 @@ namespace AppInstaller::Settings } catch (...) { - AICLI_LOG(Core, Error, << "Failed to read admin settings: unknown exception"); + AICLI_LOG(Core, Error, << "Failed to read admin settings due to unknown exception"); AICLI_LOG(Core, Info, << "Admin settings will use default values"); return; } @@ -241,7 +241,7 @@ namespace AppInstaller::Settings m_settingValues.DefaultProxy.emplace(std::move(defaultProxy)); } - AICLI_LOG(Core, Verbose, << "Admin settings loaded successfully. LocalManifestFiles=" << m_settingValues.LocalManifestFiles); + AICLI_LOG(Core, Verbose, << "Admin settings loaded successfully"); } bool AdminSettingsInternal::SaveAdminSettings() diff --git a/src/AppInstallerCommonCore/Settings.cpp b/src/AppInstallerCommonCore/Settings.cpp index 978fa16ac0..8b7d3b8d7d 100644 --- a/src/AppInstallerCommonCore/Settings.cpp +++ b/src/AppInstallerCommonCore/Settings.cpp @@ -345,7 +345,7 @@ namespace AppInstaller::Settings if (!SetVerificationData(verData)) { - AICLI_LOG(Core, Error, << "Failed to set verification data for '" << m_name << "'; reverting write"); + AICLI_LOG(Core, Error, << "Failed to write verification data for '" << m_name << "'. This may be due to insufficient permissions or disk space. The setting write will be reverted to maintain consistency."); // Verification data write failed, so we need to revert the main write // to maintain consistency Remove(); From 6bdec4d63230d7553e5131da8f1892007d8518e6 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 26 Mar 2026 00:50:48 +0000 Subject: [PATCH 4/5] Consolidate log messages per code review feedback Co-authored-by: Trenly <12611259+Trenly@users.noreply.github.com> Agent-Logs-Url: https://github.com/Trenly/winget-cli/sessions/a2b00ade-cc75-4ccf-bb63-6f81ef0e0176 --- src/AppInstallerCommonCore/AdminSettings.cpp | 6 ++---- src/AppInstallerCommonCore/Settings.cpp | 3 ++- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/AppInstallerCommonCore/AdminSettings.cpp b/src/AppInstallerCommonCore/AdminSettings.cpp index 103d09735f..619d88c0e7 100644 --- a/src/AppInstallerCommonCore/AdminSettings.cpp +++ b/src/AppInstallerCommonCore/AdminSettings.cpp @@ -187,14 +187,12 @@ namespace AppInstaller::Settings } catch (const std::exception& e) { - AICLI_LOG(Core, Error, << "Failed to read admin settings: " << e.what()); - AICLI_LOG(Core, Info, << "Admin settings will use default values"); + AICLI_LOG(Core, Error, << "Failed to read admin settings: " << e.what() << ". Falling back to default values."); return; } catch (...) { - AICLI_LOG(Core, Error, << "Failed to read admin settings due to unknown exception"); - AICLI_LOG(Core, Info, << "Admin settings will use default values"); + AICLI_LOG(Core, Error, << "Failed to read admin settings due to unknown exception. Falling back to default values."); return; } diff --git a/src/AppInstallerCommonCore/Settings.cpp b/src/AppInstallerCommonCore/Settings.cpp index 8b7d3b8d7d..b7694a7920 100644 --- a/src/AppInstallerCommonCore/Settings.cpp +++ b/src/AppInstallerCommonCore/Settings.cpp @@ -345,7 +345,8 @@ namespace AppInstaller::Settings if (!SetVerificationData(verData)) { - AICLI_LOG(Core, Error, << "Failed to write verification data for '" << m_name << "'. This may be due to insufficient permissions or disk space. The setting write will be reverted to maintain consistency."); + AICLI_LOG(Core, Error, << "Failed to write verification data for '" << m_name << "'. Reverting setting write to maintain consistency."); + AICLI_LOG(Core, Warning, << "This failure may be caused by insufficient permissions or disk space issues"); // Verification data write failed, so we need to revert the main write // to maintain consistency Remove(); From 2cd9085071cd8992bb2783996d344ceb9a235451 Mon Sep 17 00:00:00 2001 From: Kaleb Luedtke Date: Wed, 25 Mar 2026 21:26:43 -0700 Subject: [PATCH 5/5] Update release notes --- doc/ReleaseNotes.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/ReleaseNotes.md b/doc/ReleaseNotes.md index cf22c48572..ed6ed2c0b8 100644 --- a/doc/ReleaseNotes.md +++ b/doc/ReleaseNotes.md @@ -38,4 +38,4 @@ The PowerShell module now automatically uses `GH_TOKEN` or `GITHUB_TOKEN` enviro ## Bug Fixes - +* DSC export now correctly exports WinGet Admin Settings