Repository navigation
fix(config): reject reserved PostgreSQL schema prefixes - #202097
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: blocked before merge. What this changesThis PR rejects PostgreSQL schema prefixes that produce reserved schema names and updates the validation help and operator guides. Example: Configure database.postgres.schemaPrefix as pg_openclaw for a new PostgreSQL state store.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Blocked before merge - 1 item remains Keep this PR open: it fixes a source-confirmed validation bug still present on main, with no discrete code defect found. Priority: P2 Before merge
FindingsNone. Tests
Agent review detailsHow this fits togetherCLI and Gateway config loading consume the shared Zod schema; PostgreSQL store creation combines the validated prefix with the store name and identity. flowchart LR
A[User configuration] --> B[Shared config validator]
B --> C[CLI validation result]
B --> D[Gateway database selection]
D --> E[Store namespace builder]
E --> F[PostgreSQL schema creation]
Technical reviewBest possible solution: Keep the restriction in the shared config validator so CLI validation, exported schema, and Gateway startup enforce the same PostgreSQL naming contract. Do we have a high-confidence way to reproduce the issue? The main validator accepts both reserved forms, and the namespace builder deterministically produces pg_-prefixed names; the supplied PostgreSQL startup results match that path, although this review executed no target code. Is this the best way to solve the issue? The patch is the smallest complete validation fix: it strengthens the existing owner, preserves the valid pgopenclaw control, and introduces no parallel runtime policy. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against f91bc9900e81. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +3, Tests +16, Docs +5, Generated 0. Total +24 across 5 files. Added test files: 0. View PR surface stats
Preflight sourceSource unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified. LabelsLabel changes:
Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment Reviewed November 19, 2026, 5:55 PM ET / 22:55 UTC. |
6e12045 to
4eeed31
Compare
|
Merged via squash.
|
) Co-authored-by: VACInc <[email protected]>
(cherry picked from commit 3d91af2) Release adaptation: regenerate config docs hashes for this stable tree using config:docs:gen; config:docs:check passed. No config migration or anchor rename. Companions: no later PR or SHA mentions. Later same-path overlaps are unrelated config baseline regeneration, PostgreSQL operations/docs, or qualification tooling; #202109 is independent upgrade coverage, #202704 is a restore guide, and #202654 is a Session Share feature. Existing anchor selection and numeric aggregate fix #202629 are unchanged. Co-authored-by: VACInc <[email protected]> Co-authored-by: RomneyDa <[email protected]> (cherry picked from commit abc82993e59c1632ddfcaece8a02ce15c432e990)
…law#194384) * docs: clarify PostgreSQL conformance coverage * fix(cron): keep one-shot finalization working on PostgreSQL 16 * test(database): reuse cron conformance for JSON conversion regression * test(postgres): accept fractional explain row counts (cherry picked from commit 7ab0143) Release adaptation: Only engine-owned jsonValue and retained cron enabled JSON replacement; preserve native boolean type with PG16 explicit ::json and SQLite json(). Omit unrelated PG docs/EXPLAIN test edits; retained one-shot enabled-transition caller present on baseline. Follow-up dispositions: e029e18 docs: document isolated PostgreSQL restore drills (openclaw#202704); 49f0740 fix(database): report disabled memory after a port (openclaw#202630); a80b564 fix: keep database workers healthy after silent connection loss (openclaw#201856); 3d91af2 fix(config): reject reserved PostgreSQL schema prefixes (openclaw#202097); 835d722 fix: catch incompatible ownership before porting to SQLite (openclaw#202101); 67796a6 fix: keep scheduled Git backups current on PostgreSQL (openclaw#201870); cc849dd fix: recover lease heartbeats after a PostgreSQL connection loss (openclaw#201858); 6594caf fix: prepare macOS runtime pins without the PostgreSQL secret (openclaw#202102); 6ca56cd docs: clarify PostgreSQL storage and backup coverage (openclaw#202086); a079190 fix(postgres): chat history slows under concurrent reads (openclaw#190129); 2ff4256 feat(database): keep PostgreSQL rollback captures in PostgreSQL (openclaw#196236); 96c685b feat(backup): restore PostgreSQL stores into a staging database for restore drills (openclaw#194808); fb83d65 fix: reduce transcript allocation when preparing native context seeds; 71ec4d2 fix(config): keep Workboard PostgreSQL upgrades readable (openclaw#194648); b6ed907 perf(sessions): persist active transcript facts for hydration (openclaw#193682) Validation: Baseline cron generated json(bound text) on PostgreSQL where json(text) is unavailable; helper and focused boolean regression retained. Exact PostgreSQL16 server proof unavailable; focused SQLite/helper tests queued. diff check passed. Co-authored-by: RomneyDa <[email protected]> (cherry picked from commit 38fdd9b52704d588d9ca24ef8e391d644961c985) (cherry picked from commit fb935e6912388314851b05cb698ef038b83bbd07)
Summary
High Level TLDR
OpenClaw could accept a PostgreSQL schema prefix that made a new Gateway fail at startup. Config validation now points to
database.postgres.schemaPrefixand explains which values to avoid.What Problem This Solves
Using
pgorpg_openclawas the prefix passes config validation on the base commit. A fresh PostgreSQL-backed state store then fails to start because PostgreSQL reserves schema names beginning withpg_.User Impact
Operators get an actionable error during config validation. Choose a prefix such as
openclaw. Existing store anchors retain their recorded schema when the configured prefix changes.Why This Change Was Made
The config schema applies the restriction in its existing regex so CLI validation and the exported JSON Schema share one rule. The field help and PostgreSQL guides explain the restriction.
Root Cause
The config validator checked characters and length. The store owner adds an underscore after the prefix, so both bare
pgand prefixes already starting withpg_create names PostgreSQL refuses with SQLSTATE42939. PostgreSQL documents the reserved names in itsCREATE SCHEMAreference. https://www.postgresql.org/docs/17/sql-createschema.htmlEvidence
ok: true.pgopenclaw.Real behavior proof
In a fresh state directory with PostgreSQL 17.12, configure the state family to use PostgreSQL and set
database.postgres.schemaPrefixtopgorpg_openclaw. Runnode openclaw.mjs config validate --json, thennode openclaw.mjs gateway run --bind loopback --port "$PORT"with a free loopback port.Base: validation returned
"valid": truewith exit 0 for both prefixes. Gateway startup exited 1 withunacceptable schema name "pg_state_<id>"orunacceptable schema name "pg_openclaw_state_<id>". A direct PostgreSQL check returned SQLSTATE42939.Candidate: validation exited 1 and Gateway startup exited 78 with the
database.postgres.schemaPrefixerror for both values. No reserved schema was created.Valid control:
pgopenclawpassed config validation and created a real PostgreSQL state schema, and the isolated Gateway returned HTTP 200 from/ready.Published stable 2026.11.6 accepted all three prefixes. Reading the same config file with the candidate accepted
pgopenclawand rejected the two reserved prefixes. Neither CLI rewrote the config during validation. https://github.com/openclaw/openclaw/releases/tag/v2026.11.6Populated-store handoff: started the published 2026.11.6 Gateway with PostgreSQL state and ran
cron add --disabled --name "Prefix compatibility control" --every 24h --session isolated --message "Retained PostgreSQL cron message" --no-deliver --json --port "$PORT". After stopping that Gateway, started the candidate over the same config, anchor, and PostgreSQL database. The schema advanced from v36 to v40.cron list --all --json --port "$PORT"returned the same disabled job ID and payload. Config bytes, anchor store ID, and recorded namespace matched. Changing the valid configured prefix topgotherand restarting the candidate kept the original namespace and row. All three Gateway runs returned HTTP 200 from/ready.The populated-store handoff addresses the advisory review's compatibility proof request. The review found no code defects. #202097 (comment)
What was not tested
The published-to-candidate handoff used a manual switch between binaries. The installed updater, live services, and paid models were outside this check. Each Gateway used a local mock model and PostgreSQL 17 over a private Unix socket.
Verification
pnpm test src/config/zod-schema.database.test.ts --maxWorkers=1passed 35/35 (107.57 seconds locally). Main failed both new rejection cases and passed the 33 other cases.pnpm config:docs:check,pnpm config:schema:check, andgit diff --checkpassed.