fix: promote first project when config default missing from DB (#974)#985
Merged
phernandez merged 2 commits intoJun 12, 2026
Conversation
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>
c462a82 to
7a508da
Compare
There was a problem hiding this comment.
💡 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".
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
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>
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.
Summary
Fixes #974.
On a fresh install,
ConfigManagerauto-createsmainand setsdefault_project: mainin config, butbm project addonly inserts the new project into the DB. Every default-project code path then fails withProject not found: 'main'.When
add_projectruns withoutset_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_dbtest_add_project_with_set_default_falsestill passes (default unchanged when config default exists in DB)Signed-off-by: rudi193-cmd rudi193-cmd@users.noreply.github.com
Made with Cursor