Repository navigation
fix(core): leave documents.namespace to its column default when a document has none - #1806
Merged
Merged
Conversation
…ument has none A store that went through schema v11 keeps `namespace TEXT NOT NULL DEFAULT 'default'` on documents (migration v13 only dropped the unique index). The insert bound NULL to that column explicitly, so every doc create failed with "NOT NULL constraint failed: documents.namespace" on the CLI, HTTP (500) and MCP. The column is now left out of the insert when the document names no namespace: an old store stores 'default', a store created by this version keeps the column empty (documents are global, #614). The structural import had the same bind and, being INSERT OR IGNORE, skipped such documents without an error; it is fixed the same way.
🔍 Cora AI Code Review✅ No issues found. Code looks good! Review powered by cora-code · BYOK · MIT |
5 of 6 tasks
ajianaz
added a commit
that referenced
this pull request
Nov 26, 2026
Patch release: doc create on stores that went through schema v11 (#1806), the website build (#1813), the secret detector gap (#1794), list_pinned with schema v28 (#1804), dependency updates and the MCP Registry rename. Pre-release mutation gate: 2 mutants, 1 missed (Uteke::list_pinned wrapper), killed by a new test.
4 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Creating a document no longer fails with
NOT NULL constraint failed: documents.namespaceon a store whosedocumentstable still hasnamespace TEXT NOT NULL DEFAULT 'default'. The insert leaves the column out when the document names no namespace, so each kind of store applies its own default.Why
Reported against v0.24.1:
uteke doc create(insert document: missing required field),POST /doc/create(500) anduteke_doc_createall fail.Cause: a store that went through schema v11 keeps
namespace TEXT NOT NULL DEFAULT 'default'(migration v13 only drops the unique index and never rebuilds the table).Document::namespaceisNonefor every document the engine writes, and the insert bound thatNoneas an explicit NULL, so the column default never applied. The bind is the same in v0.22.1 through v0.24.1, so this is not a regression of 0.24.x; it hits stores that were created before documents became global (#614).Not covered, by design:
--namespaceondoc createis still not a document scope. Documents are global since v13 (#614, #1271). A store created by this version hasnamespace TEXT DEFAULT NULLand keeps the column empty; an old store now stores'default'.The structural import (
import_full) bound the same NULL and usesINSERT OR IGNORE, so on an old store it dropped such documents without an error. Fixed the same way.How
Two insert statements in
upsert_document_in: with thenamespacecolumn whendoc.namespaceisSome, without it whenNone. The structural import builds the column and?5slot conditionally and keeps the parameter list as it was. No schema migration: rebuildingdocumentswould have to carry the FTS triggers, the chunk and room foreign keys and the self-reference ofparent_id, and the insert fix covers old and new stores alike.Testing
cargo test --workspacepassescargo fmt --all -- --checkpassescargo clippy --workspace --all-targets -- -D warningspassescora review --base origin/develop)Schema-migration-adjacent change, so the old shape is tested directly:
a_store_with_the_old_not_null_namespace_column_takes_a_new_document: a v11-shaped database migrated to the current version, then a document upsert. Failed before the fix withinsert document: missing required field(the message of the report), passes after; the stored namespace is'default'.a_new_store_keeps_the_namespace_of_a_new_document_empty: a store created by this version still stores no namespace.a_document_without_a_namespace_imports_into_the_old_not_null_column: structural import into a store with the old column. Checked red with the fix switched off, green with it.Related Issues
Report: "doc create fails: NOT NULL constraint failed: documents.namespace (CLI, HTTP, MCP)" on v0.24.1. No GitHub issue number yet.
Checklist
fix/,feat/,docs/,chore/,refactor/,test/,perf/,security/)develop