Summary
bm project default <name> fails with No default project is currently set — but setting the default is exactly the command you reach for when none is set. The guard makes a recoverable state unrecoverable from the CLI.
Repro
Fresh config dir (e.g. isolated BASIC_MEMORY_CONFIG_DIR):
bm project add qa /tmp/bm-qa/notes --local # only project; no default row in DB
bm project default qa
# Error setting default project: No default project is currently set
Root cause
src/basic_memory/api/v2/routers/project_router.py:563-567 (set_default_project_by_id): the handler fetches the old default purely to echo it as old_project in the response, and raises 404 when there is none. The guard is marked # pragma: no cover — the no-current-default path was never tested. ProjectStatusResponse.old_project is already Optional (schemas/project_info.py:238), so the 404 serves no schema requirement.
Fix
Drop the guard; populate old_project only when a previous default exists. Add a regression test for setting a default when none is set.
Context
Found during manual QA (same session as #972). The state that exposes this comes from the config/DB reconciliation gap in #974 — the broken setter is what blocks CLI self-recovery from that state.
🤖 Generated with Claude Code
Summary
bm project default <name>fails withNo default project is currently set— but setting the default is exactly the command you reach for when none is set. The guard makes a recoverable state unrecoverable from the CLI.Repro
Fresh config dir (e.g. isolated
BASIC_MEMORY_CONFIG_DIR):Root cause
src/basic_memory/api/v2/routers/project_router.py:563-567(set_default_project_by_id): the handler fetches the old default purely to echo it asold_projectin the response, and raises 404 when there is none. The guard is marked# pragma: no cover— the no-current-default path was never tested.ProjectStatusResponse.old_projectis alreadyOptional(schemas/project_info.py:238), so the 404 serves no schema requirement.Fix
Drop the guard; populate
old_projectonly when a previous default exists. Add a regression test for setting a default when none is set.Context
Found during manual QA (same session as #972). The state that exposes this comes from the config/DB reconciliation gap in #974 — the broken setter is what blocks CLI self-recovery from that state.
🤖 Generated with Claude Code