fix(browse): log decrypt failures behind GSTACK_DEBUG in cookie-import

cookie-import-browser silently drops cookies that fail to decrypt,
leaving users unable to tell which cookies failed or why. The Keychain
entry behind Arc's Safe Storage can rotate, invalidating older
encrypted_value blobs while newer ones still decrypt, producing the
partial-import symptom reported.

Keep the existing failed counter, but surface per-row detail when
GSTACK_DEBUG=1 or DEBUG=1 is set. Log host_key and cookie name plus the
error code and message to stderr. Never log cookie values.

Closes #1057
This commit is contained in:
Matt Van Horn 2026-04-20 21:13:21 -07:00
parent e23ff280a1
commit 26e9d8be8b
No known key found for this signature in database
1 changed files with 7 additions and 1 deletions

View File

@ -279,8 +279,14 @@ export async function importCookies(
const cookie = toPlaywrightCookie(row, value);
cookies.push(cookie);
domainCounts[row.host_key] = (domainCounts[row.host_key] || 0) + 1;
} catch {
} catch (err: any) {
failed++;
if (process.env.GSTACK_DEBUG === '1' || process.env.DEBUG === '1') {
const code = err?.code ? ` [${err.code}]` : '';
console.error(
`[cookie-import] decrypt failed for ${row.host_key}/${row.name}${code}: ${err?.message ?? String(err)}`
);
}
}
}