-
-
Notifications
You must be signed in to change notification settings - Fork 10
federation create fails: SQLite reserved keyword 'commit' used as column name #201
Description
Bug
ckb federation create fails on all platforms with:
Error: failed to create federation: failed to create index: failed to initialize schema:
failed to create schema: SQL logic error: near "commit": syntax error (1)
Environment
- CKB version: 8.3.0 (commit 47da5b3, built 2026-03-28)
- macOS 15.2, ARM64 (Apple Silicon)
- SQLite driver:
modernc.org/sqlite(pure Go)
Root Cause
internal/federation/index.go uses commit as an unquoted column name in two tables:
Line 252 — remote_repos table:
CREATE TABLE IF NOT EXISTS remote_repos (
...
commit TEXT, -- ← "commit" is a SQLite reserved keyword
...
);Line 382 — same table in the migration block:
CREATE TABLE IF NOT EXISTS remote_repos (
...
commit TEXT, -- ← same issue
...
);COMMIT is a SQLite reserved keyword (used for COMMIT TRANSACTION). The modernc.org/sqlite driver enforces this strictly, causing the schema creation to fail.
The queries on lines 670, 681, and 712 also reference commit unquoted in INSERT/SELECT statements.
Proposed Fix
Option A — Quote the column name (minimal change):
- commit TEXT,
+ "commit" TEXT,Also update all references in queries (lines 670, 681, 712).
Option B — Rename the column (cleaner):
- commit TEXT,
+ commit_hash TEXT,This avoids future quoting issues and is more descriptive. Requires updating all references.
Impact
This blocks all federation functionality — ckb federation create is the entry point for multi-repo queries. No workaround exists since the schema initialization is the first step.
Reproduction
ckb federation create test
# → SQL logic error: near "commit": syntax error (1)Affected Files
internal/federation/index.go: lines 252, 382, 670, 681, 712- Possibly
internal/federation/remote_*.go(any code reading/writingremote_repos.commit)