{"record":{"id":"3293b1ce2edec45a","repo":"Yeachan-Heo/oh-my-codex","slug":"invalid-document","errorCode":"invalid_document","errorMessage":"Refusing to remove managed notification dispatcher: metadata ${metadataPath} is missing.","messagePattern":"Refusing to remove managed notification dispatcher: metadata (.+?) is missing\\.","errorType":"validation","errorClass":"ManagedCodexHooksPlanError","httpStatus":null,"severity":"error","filePath":"src/cli/setup.ts","lineNumber":3626,"sourceCode":"\t\t\tlines.splice(nextFeaturesStart, nextSectionEnd - nextFeaturesStart);\n\t\t}\n\t}\n\treturn lines.join(\"\\n\");\n}\n\ninterface DisableHooksNotifyPlan {\n\tfinalConfig: string;\n\tmetadataPath?: string;\n\tmetadataAfter: Buffer | null;\n}\n\nfunction parseDisableHooksNotifyMetadata(\n\tsnapshot: NativeHookTransactionArtifactSnapshot,\n\tmetadataPath: string,\n\tcurrentNotify: readonly string[],\n): string[] | null {\n\tif (!snapshot.bytes) {\n\t\tthrow new ManagedCodexHooksPlanError(\n\t\t\t\"invalid_document\",\n\t\t\t`Refusing to remove managed notification dispatcher: metadata ${metadataPath} is missing.`,\n\t\t);\n\t}\n\tlet parsed: unknown;\n\ttry {\n\t\tparsed = JSON.parse(decodeNativeHookTransactionUtf8(snapshot.bytes, `notification metadata ${metadataPath}`));\n\t} catch (error) {\n\t\tthrow new ManagedCodexHooksPlanError(\n\t\t\t\"invalid_document\",\n\t\t\t`Refusing to remove managed notification dispatcher: metadata ${metadataPath} is invalid JSON (${error instanceof Error ? error.message : String(error)}).`,\n\t\t);\n\t}\n\tif (!parsed || typeof parsed !== \"object\" || Array.isArray(parsed)) {\n\t\tthrow new ManagedCodexHooksPlanError(\"invalid_document\", `Refusing to remove managed notification dispatcher: metadata ${metadataPath} must be an object.`);\n\t}\n\tconst metadata = parsed as Record<string, unknown>;\n\tconst dispatcherNotify = metadata.dispatcherNotify;","sourceCodeStart":3608,"sourceCodeEnd":3644,"githubUrl":"https://github.com/Yeachan-Heo/oh-my-codex/blob/3ad79a8a6fe6e95fdbb8c00e40716fffe4011ce2/src/cli/setup.ts#L3608-L3644","documentation":"A ManagedCodexHooksPlanError (code invalid_document) thrown when planning removal of the managed notification dispatcher: the metadata snapshot has no bytes, i.e. the metadata file tracked for the transaction does not exist. The planner refuses to deconfigure hooks without proof it wrote them.","triggerScenarios":"Running disable-hooks while the OMX notify metadata JSON file at the expected path has been deleted, moved, or never written (partial earlier install, manual cleanup of ~/.codex).","commonSituations":"User manually deleted the OMX metadata file, a previous install crashed mid-transaction, or CODEX_HOME points at a different directory than the one used at install time.","solutions":["Restore or re-run `omx setup` to regenerate managed hook metadata, then disable again","Verify CODEX_HOME env var matches the home used when hooks were installed","Manually remove the notify entry from config.toml if you intentionally discarded the metadata and accept losing the pre-OMX value"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"import { existsSync } from 'node:fs';\n// before disabling hooks:\nif (!existsSync(getNotifyMetadataPath(codexHome))) {\n  // regenerate via setup or bail with a clear message\n}","typeGuard":"function isManagedPlanError(e: unknown): e is { code: string; message: string } {\n  return typeof e === 'object' && e !== null && 'code' in e && (e as any).code === 'invalid_document';\n}","tryCatchPattern":"try { await disableHooks(); } catch (e) { if (isManagedPlanError(e) && /metadata .* is missing/.test(e.message)) { await runSetupToRegenerateMetadata(); } else throw e; }","preventionTips":["Never manually delete OMX metadata files under the codex home","Keep CODEX_HOME stable between enable and disable operations"],"tags":["codex","hooks","metadata","transaction","invalid-document"],"backgroundTag":"managed-state-metadata-missing","analyzedSha":"3ad79a8a6fe6e95fdbb8c00e40716fffe4011ce2","analyzedAt":"2026-08-27T22:18:39.783Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}