{"record":{"id":"35b7a05d50533f22","repo":"can1357/oh-my-pi","slug":"unsupported-security-store-index-at-this-indexp","errorCode":null,"errorMessage":"Unsupported security store index at ${this.#indexPath()}","messagePattern":"Unsupported security store index at (.+?)","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/coding-agent/src/security/store.ts","lineNumber":222,"sourceCode":"\t\ttry {\n\t\t\tawait this.#readIndex();\n\t\t} catch (error) {\n\t\t\tif (!isEnoent(error)) throw error;\n\t\t\tawait this.#writeIndex({\n\t\t\t\tschemaVersion: STORE_SCHEMA_VERSION,\n\t\t\t\tprojectKey: this.#projectKey,\n\t\t\t\trepositoryRoot: this.#repositoryRoot,\n\t\t\t\tscanIds: [],\n\t\t\t\tplanIds: [],\n\t\t\t\tupdatedAt: new Date().toISOString(),\n\t\t\t});\n\t\t}\n\t}\n\n\tasync #readIndex(): Promise<SecurityStoreIndex> {\n\t\tconst value = (await readJsonFile(this.#indexPath())) as Partial<SecurityStoreIndex>;\n\t\tif (value.schemaVersion !== STORE_SCHEMA_VERSION || value.projectKey !== this.#projectKey) {\n\t\t\tthrow new Error(`Unsupported security store index at ${this.#indexPath()}`);\n\t\t}\n\t\tif (!Array.isArray(value.scanIds) || !value.scanIds.every(id => typeof id === \"string\")) {\n\t\t\tthrow new Error(`Invalid security store scan index at ${this.#indexPath()}`);\n\t\t}\n\t\tif (\n\t\t\tvalue.planIds !== undefined &&\n\t\t\t(!Array.isArray(value.planIds) || !value.planIds.every(id => typeof id === \"string\"))\n\t\t) {\n\t\t\tthrow new Error(`Invalid security store plan index at ${this.#indexPath()}`);\n\t\t}\n\t\treturn { ...value, planIds: value.planIds ?? [] } as SecurityStoreIndex;\n\t}\n\n\tasync #writeIndex(index: SecurityStoreIndex): Promise<void> {\n\t\tawait writeSecurityFileAtomic(this.#indexPath(), `${JSON.stringify(index, null, 2)}\\n`);\n\t}\n\n\tasync #putBundleUnlocked(input: SecurityScanBundle): Promise<void> {","sourceCodeStart":204,"sourceCodeEnd":240,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/coding-agent/src/security/store.ts#L204-L240","documentation":"SecurityStore.#readIndex validates the persisted index.json against the expected schemaVersion and the store's projectKey. A mismatch means the on-disk index was written by a different schema version or belongs to a different project, so the store refuses to interpret it rather than serving wrong data.","triggerScenarios":"Opening a SecurityStore where scans/index.json has a schemaVersion different from STORE_SCHEMA_VERSION, or a projectKey that does not match the current project directory/key (e.g. the project moved or the index was copied between projects).","commonSituations":"Upgrading or downgrading the tool between store schema versions, manually copying .omp/security data between repos, editing index.json by hand, or a partially-written/corrupt index.","solutions":["Delete the stale scans/index.json (and scans/plans directories) so the store reinitializes a fresh index","Re-run the scans/plans under the current tool version to regenerate the store","Restore the matching project layout/key, or open the store from the original project path","Check the STORE_SCHEMA_VERSION expectations of your installed version before migrating data"],"exampleFix":"// before\n// index.json: { schemaVersion: 1, projectKey: \"old-key\", ... }\n// after\nrm -rf <project>/.omp/security/scans/index.json  # let the store recreate it with current schema","handlingStrategy":"try-catch","validationCode":"const idx = await Bun.file(indexPath).json();\nif (idx.schemaVersion !== STORE_SCHEMA_VERSION || idx.projectKey !== key) console.warn(\"incompatible index\");","typeGuard":"null","tryCatchPattern":"try { openStore(dir); } catch (e) { if (String(e.message).startsWith(\"Unsupported security store index\")) { await fs.rm(indexPath); } else throw e; }","preventionTips":["Never copy stores between projects","Back up before tool upgrades"],"tags":["persistence","schema","migration"],"backgroundTag":"schema-version-mismatch","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}