mirror of
https://github.com/stablyai/orca.git
synced 2026-10-16 16:03:26 +00:00
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 <help@stably.ai>
This commit is contained in:
@@ -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<string, unknown> =>
|
||||
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']
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user