{"record":{"id":"03775c3ab804b02f","repo":"coleam00/Archon","slug":"container-env-envid-not-found-its-tracking-r","errorCode":null,"errorMessage":"Container env '${envId}' not found (its tracking row is gone).","messagePattern":"Container env '(.+?)' not found \\(its tracking row is gone\\)\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/isolation/src/backends/container.ts","lineNumber":472,"sourceCode":"\n  /**\n   * Discard the overlay diff (write-back rejected). The live root is never touched;\n   * the volume is reclaimed by the caller's subsequent `destroy`. A no-op beyond a\n   * breadcrumb — the discard IS \"do nothing to the live root, then destroy\".\n   */\n  async discardChanges(envId: string): Promise<void> {\n    log.info({ envId }, 'isolation.container_changes_discarded');\n  }\n\n  /**\n   * Load a container env's persisted metadata, or throw if the row is gone. The\n   * store normalizes `metadata` to a parsed object on every dialect (SQLite returns\n   * it as a JSON string otherwise), so this reads it directly.\n   */\n  private async loadMetadata(envId: string): Promise<Partial<ContainerEnvMetadata>> {\n    const row = await this.store.getById(envId);\n    if (!row) {\n      throw new Error(`Container env '${envId}' not found (its tracking row is gone).`);\n    }\n    return row.metadata as Partial<ContainerEnvMetadata>;\n  }\n\n  private preparedEnvFor(\n    containerId: string,\n    cwd: string,\n    envId: string,\n    overlayMode: OverlayMode\n  ): PreparedEnv {\n    return { cwd, execContext: { kind: 'container', containerId }, envId, overlayMode };\n  }\n\n  /**\n   * Container presence as three outcomes: `running`, `stopped` (exists but not\n   * running), or `missing` (no such container). Distinct from {@link containerState}\n   * which folds \"missing\" and \"inspect blip\" into `unknown` — resume MUST tell\n   * \"gone\" (→ recreate over the volume) apart from \"stopped\" (→ start).","sourceCodeStart":454,"sourceCodeEnd":490,"githubUrl":"https://github.com/coleam00/Archon/blob/0773b9745896ef0612e709c80845a0f7db315b19/packages/isolation/src/backends/container.ts#L454-L490","documentation":"loadMetadata looks up a container environment's tracking row in the isolation store by id. When the row is absent the env's persisted state (metadata) cannot be recovered, so the library throws instead of fabricating a partial metadata object.","triggerScenarios":"Calling meta() (directly or indirectly) with an envId that no longer exists in the store — e.g. the row was pruned by cleanup, the env was removed concurrently, or the id is stale/typo'd.","commonSituations":"Calling meta() for an env that was already removed by another process; a deleted database or schema reset wiping rows; passing an id from a previous run after re-initializing the store.","solutions":["Verify the envId exists by listing current container envs before reading metadata","Re-create or resume the environment if the id is stale","Check whether cleanup/pruning removed the tracking row and restore the database backup if needed"],"exampleFix":"// before\nconst metadata = await backend.meta('env-abc123');\n// after\nconst envs = await backend.listEnvs?.() ?? [];\nif (!envs.some(e => e.id === 'env-abc123')) throw new Error('env not found');\nconst metadata = await backend.meta('env-abc123');","handlingStrategy":"validation","validationCode":"const exists = await store.getById(envId);\nif (!exists) throw new Error(`Unknown env id: ${envId}`);\nconst metadata = await backend.meta(envId);","typeGuard":"function isEnvRow(row: unknown): row is { id: string; metadata: Record<string, unknown> } {\n  return typeof row === 'object' && row !== null && 'id' in row && 'metadata' in row;\n}","tryCatchPattern":"try {\n  return await backend.meta(envId);\n} catch (err) {\n  if (String(err).includes('not found (its tracking row is gone)')) {\n    return null; // treat as absent env\n  }\n  throw err;\n}","preventionTips":["List available env ids before dereferencing metadata","Avoid holding env ids across cleanups or store resets","Handle concurrent cleanup races by re-listing after a not-found"],"tags":["docker","state","not-found"],"backgroundTag":"container-env-tracking-row-missing","analyzedSha":"0773b9745896ef0612e709c80845a0f7db315b19","analyzedAt":"2026-09-01T02:28:07.064Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}