Skip to content

Fresh config via 'project add' leaves config/DB inconsistent: auto-created 'main' is default in config but never synced to the DB #974

@groksrc

Description

@groksrc

Summary

On a brand-new config dir, the first bm project add <name> produces a wedged state: config.json contains the auto-created main project AND default_project: "main", but the projects table only contains the explicitly added project — and no row has is_default=1. Every default-project code path then fails with Project not found: 'main'.

Repro

export BASIC_MEMORY_CONFIG_DIR=/tmp/bm-fresh/config BASIC_MEMORY_HOME=/tmp/bm-fresh/home
bm project add qa /tmp/bm-fresh/notes --local
bm tool read-note "anything"
# Error during read_note: Project not found: 'main'
bm project list   # shows only 'qa'

config.json after: projects = {main: $BASIC_MEMORY_HOME, qa: ...}, default_project: main. DB after: only qa, is_default empty everywhere.

Root cause (observed, not fully traced)

ConfigManager auto-creates main (config.py ~:191) when initializing a fresh config, but project add only inserts the added project into the DB — nothing reconciles the auto-created main (or the default_project pointer) into the projects table. Reconciliation presumably happens on some other path (server/sync startup), which a CLI-only flow never hits.

Severity

Combined with the set-default bug (filed separately), the user cannot self-heal from the CLI: reads fail on the missing default and bm project default <name> refuses to run. Workaround today: pass --project everywhere or hand-edit config.json.

Possible directions

  • Reconcile config projects -> DB during project add / CLI init (same reconciliation the server path uses)
  • Or: don't auto-create main/default_project in config when the first real action is an explicit project add — make the added project the default when it is the only one

Found during manual QA (same session as #972).

🤖 Generated with Claude Code

Metadata

Metadata

Assignees

Labels

bugSomething isn't working
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions