Skip to content

fix: promote first project when config default missing from DB (#974)#985

Merged
phernandez merged 2 commits into
basicmachines-co:mainfrom
rudi193-cmd:fix/974-fresh-config-default-promotion
Jun 12, 2026
Merged

fix: promote first project when config default missing from DB (#974)#985
phernandez merged 2 commits into
basicmachines-co:mainfrom
rudi193-cmd:fix/974-fresh-config-default-promotion

Conversation

@rudi193-cmd

Copy link
Copy Markdown
Contributor

Summary

Fixes #974.

On a fresh install, ConfigManager auto-creates main and sets default_project: main in config, but bm project add only inserts the new project into the DB. Every default-project code path then fails with Project not found: 'main'.

When add_project runs without set_default=True, we now promote the newly added project if the configured default name has no row in the projects table (config + DB stay aligned).

Test plan

  • pytest tests/services/test_project_service.py::test_add_project_promotes_when_config_default_missing_from_db
  • Existing test_add_project_with_set_default_false still passes (default unchanged when config default exists in DB)

Signed-off-by: rudi193-cmd rudi193-cmd@users.noreply.github.com

Made with Cursor

Fresh CLI installs auto-create main in config but never sync it to the
projects table; the first project add now becomes default when the
configured default has no DB row. Fixes basicmachines-co#974.

Signed-off-by: rudi193-cmd <rudi193@gmail.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
@rudi193-cmd rudi193-cmd force-pushed the fix/974-fresh-config-default-promotion branch from c462a82 to 7a508da Compare June 12, 2026 12:46

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c462a82933

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/basic_memory/services/project_service.py
When add_project promotes a new project because the configured default is missing from the database, return the persisted default flag instead of echoing the request flag.

Signed-off-by: rudi193-cmd <rudi193@gmail.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
@phernandez phernandez merged commit 25732b2 into basicmachines-co:main Jun 12, 2026
5 checks passed
phernandez added a commit that referenced this pull request Jun 12, 2026
…sing config default

Follow-up to #985 (the #974 fix by @rudi193-cmd), addressing the codex P2
raised on #987: when config's default_project has no database row but the
database still holds a valid default of its own, promoting the just-added
project would silently steal that default. The repair now repoints config
at a surviving database default — matching synchronize_projects, which
treats the database default as authoritative — and promotes the added
project only when no usable database default exists (no default at all,
or one unknown to config, which set_default_project rejects and
reconciliation deletes).

Also removes an unused ProjectConfig import from the #985 regression test
(strict ruff failure; CI's --fix lint masked it).

Refs #974

Signed-off-by: phernandez <paul@basicmachines.co>
phernandez added a commit that referenced this pull request Jun 12, 2026
…sing config default

Follow-up to #985 (the #974 fix by @rudi193-cmd), addressing the codex P2
raised on #987: when config's default_project has no database row but the
database still holds a valid default of its own, promoting the just-added
project would silently steal that default. The repair now repoints config
at a surviving database default — matching synchronize_projects, which
treats the database default as authoritative — and promotes the added
project only when no usable database default exists (no default at all,
or one unknown to config, which set_default_project rejects and
reconciliation deletes).

Also removes an unused ProjectConfig import from the #985 regression test
(strict ruff failure; CI's --fix lint masked it).

Refs #974

Signed-off-by: phernandez <paul@basicmachines.co>
phernandez added a commit that referenced this pull request Jun 12, 2026
… empty projects table

On a brand-new config dir, model_post_init bootstraps a 'main' default in
config.json but the one-shot CLI path never runs the server-lifespan
reconciliation that would create its database row, so the first read fails
with a bare "Project not found: 'main'" — which reads as a broken install
rather than a missing first-run step. When resolution misses and the
projects table is empty, the 404 now names the setup command.

Follow-up to #974/#985/#987 (which repair the default during project add
but cannot help when the first action is a read). Refs #974.

Signed-off-by: phernandez <paul@basicmachines.co>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

2 participants