{"record":{"id":"95b24b84b66da56f","repo":"zeroclaw-labs/zeroclaw","slug":"memory-backend-postgres-requested-but-this-build","errorCode":null,"errorMessage":"memory backend 'postgres' requested but this build was compiled without `memory-postgres`; rebuild with `--features memory-postgres`","messagePattern":"memory backend 'postgres' requested but this build was compiled without `memory-postgres`; rebuild with `--features memory-postgres`","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/zeroclaw-memory/src/lib.rs","lineNumber":110,"sourceCode":"    use postgres::PostgresMemory;\n    let db_url = storage\n        .db_url\n        .as_deref()\n        .context(\"memory backend 'postgres' requires [storage.postgres.<alias>].db_url\")?;\n    PostgresMemory::new(\n        \"postgres\",\n        db_url,\n        &storage.schema,\n        &storage.table,\n        storage.connect_timeout_secs,\n        Some(storage.vector_enabled),\n        Some(storage.vector_dimensions),\n    )\n}\n\n#[cfg(not(feature = \"memory-postgres\"))]\nfn build_postgres_memory(_storage: &PostgresStorageConfig) -> anyhow::Result<Box<dyn Memory>> {\n    anyhow::bail!(\n        \"memory backend 'postgres' requested but this build was compiled without \\\n         `memory-postgres`; rebuild with `--features memory-postgres`\"\n    )\n}\n\n/// Wrap the backend in the `AuditedMemory` decorator when\n/// `[memory] audit_enabled = true`; pass it through untouched otherwise\n/// (the default), so the flag-off path is byte-identical to an unwrapped\n/// backend.\nfn wrap_audit<M: Memory + 'static>(\n    memory: M,\n    workspace_dir: &Path,\n    audit_enabled: bool,\n) -> anyhow::Result<Box<dyn Memory>> {\n    if audit_enabled {\n        Ok(Box::new(AuditedMemory::new(memory, workspace_dir)?))\n    } else {\n        Ok(Box::new(memory))","sourceCodeStart":92,"sourceCodeEnd":128,"githubUrl":"https://github.com/zeroclaw-labs/zeroclaw/blob/88bb9c8533fc57ed7a03e36ca7c9ed2bf8336dcc/crates/zeroclaw-memory/src/lib.rs#L92-L128","documentation":"The memory factory selected the PostgreSQL backend, but the zeroclaw-memory crate was compiled without the optional `memory-postgres` Cargo feature. In feature-less builds, build_postgres_memory is a stub whose only job is to fail with this message. PostgreSQL support is compile-time optional so the postgres client dependency stays out of default builds.","triggerScenarios":"Setting `memory.backend = \"postgres\"` (or `\"postgres.<alias>\"`) in the active config and constructing memory via create_memory, create_memory_from_config, or create_memory_with_storage_and_routes on a binary built with default features. The postgres branch resolves the [storage.postgres.<alias>] entry, then hits the cfg(not(feature))-gated stub.","commonSituations":"Running a distribution or plain `cargo build` artifact against a config written for a feature-enabled deployment; CI building without `--features memory-postgres`; assuming the postgres client dependency ships by default; upgrading a deployment where the new build recipe dropped the feature.","solutions":["Rebuild with the feature enabled: `cargo build --features memory-postgres` (or enable the workspace/bin feature that forwards to zeroclaw-memory's memory-postgres).","If PostgreSQL is not required, switch the config to a backend that ships by default: `memory.backend = \"sqlite\"`, `\"lucid\"`, `\"markdown\"`, or `\"qdrant\"`.","Verify the artifact actually has the feature before deploying, e.g. `cargo tree -e features -i tokio-postgres` against the build recipe."],"exampleFix":"# before\n# build: cargo build\n[memory]\nbackend = \"postgres.main\"\n\n# after\n# build: cargo build --features memory-postgres\n[memory]\nbackend = \"postgres.main\"","handlingStrategy":"validation","validationCode":"// In the binary/service crate, fail fast at startup instead of first memory use\n#[cfg(not(feature = \"memory-postgres\"))]\nif config.memory.backend.split('.').next() == Some(\"postgres\") {\n    anyhow::bail!(\n        \"config selects the postgres memory backend but this build lacks `memory-postgres`; \\\n         rebuild with --features memory-postgres or change memory.backend\"\n    );\n}","typeGuard":null,"tryCatchPattern":"let memory = match create_memory_from_config(&config, api_key) {\n    Ok(m) => m,\n    Err(e) if e.to_string().contains(\"memory-postgres\") => {\n        // operator-actionable: rebuild the binary or switch memory.backend\n        return Err(e.context(\"postgres backend selected in a build without memory-postgres\"));\n    }\n    Err(e) => return Err(e),\n};","preventionTips":["Fail CI when a shipped config references the postgres backend but the artifact was built without --features memory-postgres.","Construct memory eagerly at startup (config self-check) so feature mismatches surface at boot, not mid-conversation.","Keep build recipes and config templates in the same repo so backend choices and feature flags cannot drift."],"tags":["postgres","feature-flag","build-config","rust","memory-backend"],"backgroundTag":"missing-compile-time-feature","analyzedSha":"88bb9c8533fc57ed7a03e36ca7c9ed2bf8336dcc","analyzedAt":"2026-08-23T01:07:41.857Z","schemaVersion":2},"datasetVersion":"2026-08-23T08:06:27.607Z"}