@@ -34,6 +34,9 @@ export type AccountSelectionFallbacks = Pick<
3434 "accountIdOverride" | "accountIdSource" | "organizationIdOverride" | "accountLabel"
3535> ;
3636
37+ const PERSIST_AUTHENTICATED_SELECTIONS_ERROR =
38+ "Failed to persist authenticated account selections." ;
39+
3740const createSelectionVariant = (
3841 tokens : TokenSuccess ,
3942 candidate : {
@@ -163,8 +166,8 @@ export function applyAccountSelectionFallbacks(
163166 * that callback, so callers should use `persistAccountPool` or
164167 * `withAccountStorageTransaction` to keep the rename retry and serialized
165168 * read-modify-write behavior covered by `test/login-runner.test.ts`.
166- * This helper does not log token material; callers must redact any callback
167- * failure details before emitting logs .
169+ * Callback failures are rethrown with a redacted message so callers can log the
170+ * wrapper safely without leaking token-file paths or account identifiers .
168171 */
169172export async function persistResolvedAccountSelection (
170173 selection : AccountSelectionResult ,
@@ -177,10 +180,16 @@ export async function persistResolvedAccountSelection(
177180 return selection ;
178181 }
179182
180- await options . persistSelections (
181- selection . variantsForPersistence ,
182- options . replaceAll ?? false ,
183- ) ;
183+ try {
184+ await options . persistSelections (
185+ selection . variantsForPersistence ,
186+ options . replaceAll ?? false ,
187+ ) ;
188+ } catch ( error ) {
189+ throw new Error ( PERSIST_AUTHENTICATED_SELECTIONS_ERROR , {
190+ cause : error ,
191+ } ) ;
192+ }
184193 return selection ;
185194}
186195
@@ -190,8 +199,8 @@ export async function persistResolvedAccountSelection(
190199 * serialization remain the callback's responsibility, so callers should route
191200 * through `persistAccountPool` or `withAccountStorageTransaction` to preserve
192201 * the guarantees covered by `test/login-runner.test.ts`.
193- * This helper does not log tokens or account identifiers; callers must redact
194- * callback failures before logging them .
202+ * Persistence callback failures are redacted inside
203+ * `persistResolvedAccountSelection()` before they propagate back to callers .
195204 */
196205export async function resolveAndPersistAccountSelection (
197206 tokens : TokenSuccess ,
0 commit comments