{"record":{"id":"346c36bb757a7da3","repo":"zeroclaw-labs/zeroclaw","slug":"postgres-backend-requires-storage-config-call-cre","errorCode":null,"errorMessage":"postgres backend requires storage config; call create_memory_with_storage_and_routes instead of create_memory_with_builders","messagePattern":"postgres backend requires storage config; call create_memory_with_storage_and_routes instead of create_memory_with_builders","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/zeroclaw-memory/src/lib.rs","lineNumber":173,"sourceCode":") -> anyhow::Result<Box<dyn Memory>>\nwhere\n    F: FnMut() -> anyhow::Result<SqliteMemory>,\n{\n    match classify_memory_backend(backend_name) {\n        MemoryBackendKind::Sqlite => {\n            wrap_scanned_and_audit(sqlite_builder()?, policy, workspace_dir, audit_enabled)\n        }\n        MemoryBackendKind::Lucid => {\n            let local = sqlite_builder()?;\n            wrap_scanned_and_audit(\n                LucidMemory::new(\"lucid\", workspace_dir, local),\n                policy,\n                workspace_dir,\n                audit_enabled,\n            )\n        }\n        MemoryBackendKind::Postgres => {\n            anyhow::bail!(\n                \"postgres backend requires storage config; \\\n                 call create_memory_with_storage_and_routes instead of create_memory_with_builders\"\n            )\n        }\n        MemoryBackendKind::Qdrant | MemoryBackendKind::Markdown => wrap_scanned_and_audit(\n            MarkdownMemory::new(\"markdown\", workspace_dir),\n            policy,\n            workspace_dir,\n            audit_enabled,\n        ),\n        MemoryBackendKind::None => wrap_scanned_and_audit(\n            NoneMemory::new(\"none\"),\n            policy,\n            workspace_dir,\n            audit_enabled,\n        ),\n        MemoryBackendKind::Unknown => {\n            ::zeroclaw_log::record!(WARN, ::zeroclaw_log::Event::new(module_path!(), ::zeroclaw_log::Action::Note).with_outcome(::zeroclaw_log::EventOutcome::Unknown).with_attrs(::serde_json::json!({\"backend_name\": backend_name, \"unknown_context\": unknown_context})), \"Unknown memory backend '', falling back to markdown\");","sourceCodeStart":155,"sourceCodeEnd":191,"githubUrl":"https://github.com/zeroclaw-labs/zeroclaw/blob/88bb9c8533fc57ed7a03e36ca7c9ed2bf8336dcc/crates/zeroclaw-memory/src/lib.rs#L155-L191","documentation":"create_memory_with_builders constructs memory from a MemoryBackendKind plus builder closures, and that signature has no way to carry the PostgreSQL connection settings ([storage.postgres.<alias>]) the postgres backend requires. Rather than inventing connection defaults, the factory refuses the postgres kind on this entry point and points at the API that accepts full storage config. This is an API-shape mismatch, not an environment problem.","triggerScenarios":"Calling create_memory_with_builders with MemoryBackendKind::Postgres, or reaching it via create_memory_for_migration with a postgres backend. Typical trigger: a generic dispatch layer that maps backend strings to kinds and funnels every backend through the builders API.","commonSituations":"Code that treats all backends uniformly through the builders API; tests written against sqlite and later pointed at postgres; refactors that bypass the Config-based factories; copy-pasted factory calls from sqlite-only code paths.","solutions":["Route postgres configs through create_memory_with_storage_and_routes (or create_memory_from_config), which resolves the [storage.postgres.<alias>] entry.","If you must keep one call site, dispatch: builders API for sqlite/markdown-family backends, storage-aware factory for postgres."],"exampleFix":"// before\nlet mem = create_memory_with_builders(\n    &\"postgres\".to_string(), workspace_dir,\n    || build_sqlite(...), \"\", &config.policy, config.audit_enabled,\n)?;\n\n// after\nlet mem = create_memory_from_config(&config, api_key)?;","handlingStrategy":"type-guard","validationCode":"if matches!(classify_memory_backend(&backend_name), MemoryBackendKind::Postgres) {\n    anyhow::bail!(\n        \"postgres backend requires storage config; use create_memory_with_storage_and_routes\"\n    );\n}","typeGuard":"fn builders_api_supports(kind: MemoryBackendKind) -> bool {\n    !matches!(kind, MemoryBackendKind::Postgres)\n}","tryCatchPattern":null,"preventionTips":["Route all Config-driven construction through create_memory_from_config — it dispatches postgres to the storage-aware factory.","In generic dispatch layers, branch postgres to create_memory_with_storage_and_routes instead of funnelling every kind through the builders API."],"tags":["postgres","api-misuse","factory","storage-config"],"backgroundTag":"unsupported-argument-combination","analyzedSha":"88bb9c8533fc57ed7a03e36ca7c9ed2bf8336dcc","analyzedAt":"2026-08-23T01:07:41.857Z","schemaVersion":2},"datasetVersion":"2026-08-23T08:06:27.607Z"}