From ff165afc5fe36d68447ffb81176db3cabd740451 Mon Sep 17 00:00:00 2001 From: Neil <4138956+nwparker@users.noreply.github.com> Date: Thu, 2 Jul 2026 02:50:34 -0700 Subject: [PATCH] Reject null/array pr-issue shapes when reading the github cache sidecar A corrupt-but-valid-JSON sidecar ({"pr":null}) would seed state.githubCache.pr = null and crash mobile worktree.ps PR grouping until the renderer's first cache save repaired it. Co-authored-by: Orca --- src/main/persistence.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/main/persistence.ts b/src/main/persistence.ts index 3ecb9fd226a..fb25286488c 100644 --- a/src/main/persistence.ts +++ b/src/main/persistence.ts @@ -338,11 +338,12 @@ function getGithubCacheFile(): string { function readGithubCacheSnapshot(): PersistedState['githubCache'] | null { try { const parsed = JSON.parse(readFileSync(getGithubCacheFile(), 'utf-8')) as unknown + const isPlainRecord = (value: unknown): value is Record => + typeof value === 'object' && value !== null && !Array.isArray(value) if ( - parsed && - typeof parsed === 'object' && - typeof (parsed as { pr?: unknown }).pr === 'object' && - typeof (parsed as { issue?: unknown }).issue === 'object' + isPlainRecord(parsed) && + isPlainRecord((parsed as { pr?: unknown }).pr) && + isPlainRecord((parsed as { issue?: unknown }).issue) ) { return parsed as PersistedState['githubCache'] }