[PR #4387] [MERGED] Launcher: say when Windows Credential Manager is full (error 8), and keep the old sign-in when a save stops partway #5596

Closed
opened 2026-11-03 05:13:40 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/4387
Author: @ludovic111
Created: 10/30/2026
Status: ✅ Merged
Merged: 10/30/2026
Merged by: @ludovic111

Base: main ← Head: fix/windows-credential-manager-full


📝 Commits (1)

  • 66f4bfb Launcher: say when Windows Credential Manager is full, and keep the old sign-in when a save stops partway

📊 Changes

3 files changed (+194 additions, -47 deletions)

View changed files

📝 docs/microsoft-account.md (+11 -0)
📝 launcher/src/account.rs (+117 -46)
📝 launcher/src/account/tests.rs (+66 -1)

📄 Description

🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself.

Refs #4313, #4366: Windows players signing in to their Microsoft account in the launcher get "Platform secure storage failure: Windows error code 8". This PR does not make their sign-in work by itself, because the cause is on their PC. It replaces the bare code with what is wrong and what to do.

Cause

  • The screenshots show the keyring crate's message for a Credential Manager failure: PlatformFailure(Windows error code 8). It comes from CredWriteW while Accounts::add saves the new sign-in's secrets. The device code, the Microsoft/Xbox/Minecraft token exchange and the ownership check had all succeeded already.
  • Code 8 is ERROR_NOT_ENOUGH_MEMORY. From Credential Manager it doesn't mean RAM: it means the user's credential store reached its undocumented total size. Every new item is then refused, whatever its size; an item over 2560 bytes fails with 1783 instead. Others have reported the same: GitHub Desktop (desktop/desktop#15217, Visual Studio, VS Code's keychain troubleshooting), DamianEdwards/ghcp-spend-tray#33 and jlcodes99/cockpit-tools#2924, where 100/490/2000-byte writes failed with 8 and worked after cleanup.
  • Minecraft players are likely to hit it. In those reports, the stores were filled with hundreds of XblGrts… / Xbl|… items, which the Xbox app and the Minecraft Launcher leave behind.
  • Our items are small: a sign-in is split into pieces of at most 1000 UTF-8 bytes, under 2000 bytes each (#2879). That split is already in the Nightly fbd7288, so the per-item limit is not the cause.

What changes

  1. A clear message (CREDENTIAL_MANAGER_FULL) when a Credential Manager write fails with code 8: the store is full, it isn't the computer's memory, open Credential Manager → Windows Credentials, remove unused entries, sign in again. It also names the Xbox/Minecraft Launcher entries and warns that removing an entry can sign its app out. The sign-in dialog, the CLI and the "renewed sign-in couldn't be saved" notice all show it. Other codes keep the keyring crate's text. The launcher never deletes other apps' items and never falls back to a file.
  2. No more half-written secrets. Before, if writing a piece after the first one failed (a renewal into a nearly full store), new pieces sat in front of old ones. The secret then read back as invalid JSON, and the account was "no longer signed in" at the next start. Now the old secret is put back (it fit before), so the account keeps its previous sign-in. The piece logic now runs over a small Items trait, so it is tested with a fake store that fills up, on every OS.
  3. docs/microsoft-account.md: the Credential Manager full case and the rollback.

The owner gate is untouched: a sign-in that can't be saved still isn't added, exactly as before.

#3249 / #3711 (logged out on reopen)

Mostly a different cause: the Linux GTK_USE_PORTAL keyring file, fixed by #3769. The Windows report in #3249 can share this one: on a nearly full Credential Manager, a renewal could half-write its pieces and leave the account signed out on reopen. Change 2 removes that path. That is a plausible cause, not a proven one, so this PR doesn't close those issues.

Testing

  • a_secret_the_keychain_cant_finish_keeps_the_old_one: a store with room for 2 items. A 3-piece renewal fails with the new message, and the old 2-piece secret reads back whole. A sign-in into a full store keeps nothing. Once there is room, longer and shorter secrets replace the old one whole, with no leftover pieces.
  • credential_manager_error_8_says_the_store_is_full: code 8 is mapped; 5 and 1312 are not.
  • The Windows-only downcast (keyring::windows::Error) was type-checked against keyring 3.6.3 for x86_64-pc-windows-msvc in a scratch crate. The full launcher doesn't cross-build here (ring needs the Windows SDK). CI builds Windows.
  • No Windows machine here. Steps for a Windows contributor: run cmdkey /list | find /c "Target:" to count entries. To test the message without filling a healthy store, use a profile where cmdkey /generic:horizon-test /user:x /pass:x already fails with "Not enough memory resources are available to process this command". Sign in from the launcher and expect the new message. Remove a few unused entries, sign in again, and expect it to work and survive a restart. Delete the test entry with cmdkey /delete:horizon-test. Don't fill a working store on purpose.

pr_ready (tools/pr_ready.py --quick on ludovics-mac-mini, against origin/main at 5c34936e1, 1 min 42 s)

Check Result
Scope ✅ 3 files, +194 −47
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ✅ 480 passed (1 min 31 s)
rustfmt ➖ no Rust change
clippy ➖ no Rust change
tests ➖ no crate touched
doc tests ➖ no crate touched
content root tests ➖ content root untouched
tokens.css up to date ➖ theme untouched
launcher rustfmt ✅ (1 s)
launcher clippy ✅ (2 s)
launcher tests ✅ 280 passed (8 s)
Parity ➖ 1 affected, to run in CI (--quick): lan_integration
Label player-facing: feature if players get something new, no label for a fix (release-now if urgent)

🤖 Generated with Claude Code


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/horizon-rust/horizon/pull/4387 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 10/30/2026 **Status:** ✅ Merged **Merged:** 10/30/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/windows-credential-manager-full` --- ### 📝 Commits (1) - [`66f4bfb`](https://github.com/horizon-rust/horizon/commit/66f4bfbaaebc1695dccb4f78125e07158407e255) Launcher: say when Windows Credential Manager is full, and keep the old sign-in when a save stops partway ### 📊 Changes **3 files changed** (+194 additions, -47 deletions) <details> <summary>View changed files</summary> 📝 `docs/microsoft-account.md` (+11 -0) 📝 `launcher/src/account.rs` (+117 -46) 📝 `launcher/src/account/tests.rs` (+66 -1) </details> ### 📄 Description > 🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself. Refs #4313, #4366: Windows players signing in to their Microsoft account in the launcher get "Platform secure storage failure: Windows error code 8". This PR does not make their sign-in work by itself, because the cause is on their PC. It replaces the bare code with what is wrong and what to do. ## Cause - The screenshots show the `keyring` crate's message for a Credential Manager failure: `PlatformFailure(Windows error code 8)`. It comes from `CredWriteW` while `Accounts::add` saves the new sign-in's secrets. The device code, the Microsoft/Xbox/Minecraft token exchange and the ownership check had all succeeded already. - Code 8 is `ERROR_NOT_ENOUGH_MEMORY`. From Credential Manager it doesn't mean RAM: it means the user's credential store reached its undocumented total size. Every new item is then refused, whatever its size; an item over 2560 bytes fails with 1783 instead. Others have reported the same: GitHub Desktop (desktop/desktop#15217, Visual Studio, VS Code's keychain troubleshooting), DamianEdwards/ghcp-spend-tray#33 and jlcodes99/cockpit-tools#2924, where 100/490/2000-byte writes failed with 8 and worked after cleanup. - Minecraft players are likely to hit it. In those reports, the stores were filled with hundreds of `XblGrts…` / `Xbl|…` items, which the Xbox app and the Minecraft Launcher leave behind. - Our items are small: a sign-in is split into pieces of at most 1000 UTF-8 bytes, under 2000 bytes each (#2879). That split is already in the Nightly fbd7288, so the per-item limit is not the cause. ## What changes 1. **A clear message** (`CREDENTIAL_MANAGER_FULL`) when a Credential Manager write fails with code 8: the store is full, it isn't the computer's memory, open Credential Manager → Windows Credentials, remove unused entries, sign in again. It also names the Xbox/Minecraft Launcher entries and warns that removing an entry can sign its app out. The sign-in dialog, the CLI and the "renewed sign-in couldn't be saved" notice all show it. Other codes keep the keyring crate's text. The launcher never deletes other apps' items and never falls back to a file. 2. **No more half-written secrets.** Before, if writing a piece after the first one failed (a renewal into a nearly full store), new pieces sat in front of old ones. The secret then read back as invalid JSON, and the account was "no longer signed in" at the next start. Now the old secret is put back (it fit before), so the account keeps its previous sign-in. The piece logic now runs over a small `Items` trait, so it is tested with a fake store that fills up, on every OS. 3. `docs/microsoft-account.md`: the Credential Manager full case and the rollback. The owner gate is untouched: a sign-in that can't be saved still isn't added, exactly as before. ## #3249 / #3711 (logged out on reopen) Mostly a different cause: the Linux `GTK_USE_PORTAL` keyring file, fixed by #3769. The Windows report in #3249 can share this one: on a nearly full Credential Manager, a renewal could half-write its pieces and leave the account signed out on reopen. Change 2 removes that path. That is a plausible cause, not a proven one, so this PR doesn't close those issues. ## Testing - `a_secret_the_keychain_cant_finish_keeps_the_old_one`: a store with room for 2 items. A 3-piece renewal fails with the new message, and the old 2-piece secret reads back whole. A sign-in into a full store keeps nothing. Once there is room, longer and shorter secrets replace the old one whole, with no leftover pieces. - `credential_manager_error_8_says_the_store_is_full`: code 8 is mapped; 5 and 1312 are not. - The Windows-only downcast (`keyring::windows::Error`) was type-checked against keyring 3.6.3 for `x86_64-pc-windows-msvc` in a scratch crate. The full launcher doesn't cross-build here (ring needs the Windows SDK). CI builds Windows. - No Windows machine here. **Steps for a Windows contributor:** run `cmdkey /list | find /c "Target:"` to count entries. To test the message without filling a healthy store, use a profile where `cmdkey /generic:horizon-test /user:x /pass:x` already fails with "Not enough memory resources are available to process this command". Sign in from the launcher and expect the new message. Remove a few unused entries, sign in again, and expect it to work and survive a restart. Delete the test entry with `cmdkey /delete:horizon-test`. Don't fill a working store on purpose. **pr_ready** (`tools/pr_ready.py --quick` on ludovics-mac-mini, against origin/main at 5c34936e1, 1 min 42 s) | Check | Result | | --- | --- | | Scope | ✅ 3 files, +194 −47 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ✅ 480 passed (1 min 31 s) | | rustfmt | ➖ no Rust change | | clippy | ➖ no Rust change | | tests | ➖ no crate touched | | doc tests | ➖ no crate touched | | content root tests | ➖ content root untouched | | tokens.css up to date | ➖ theme untouched | | launcher rustfmt | ✅ (1 s) | | launcher clippy | ✅ (2 s) | | launcher tests | ✅ 280 passed (8 s) | | Parity | ➖ 1 affected, to run in CI (--quick): lan_integration | | Label | player-facing: `feature` if players get something new, no label for a fix (`release-now` if urgent) | 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 05:13:40 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
horizon-rust/horizon#5596
No description provided.