-
Notifications
You must be signed in to change notification settings - Fork 155
fix: read default project from database in cloud mode #520
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
In cloud mode, the database is the source of truth for project configuration, but the v1 API endpoints were reading the default project from the config file (via ProjectService.default_project property), which is never updated in cloud mode. This caused a state mismatch where: - Setting a project as default updates the database only (not config file) - But deletion/retrieval checks the config file (not database) - So even after setting a different project as default, the config file still thinks 'main' is default, blocking deletion Fix: - In remove_project and get_default_project endpoints, check database first - Fall back to config file if database has no default (local mode) - This works for both cloud mode (database is source of truth) and local mode (config file is source of truth) Related: basicmachines-co/basic-memory-cloud#397 Related: #397 (original fix for config auto-creation) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
|
Claude finished @phernandez's task in 2m 15s —— View job PR Review Complete ✅I've reviewed PR #520 against the Basic Memory team checklist. Here's my analysis: SummaryThis PR correctly fixes a cloud mode bug where users couldn't delete the The fix adds database-first logic with config fallback, maintaining backwards compatibility for local mode while fixing cloud mode. Code Quality & Standards ✅Follows Basic Memory Conventions
Comments & Documentation
Suggested improvement for lines 324-330 in # Trigger: Determining which project is default before allowing deletion
# Why: In cloud mode, config file is stale (never updated), but database is source of truth.
# In local mode, both are synced, so config provides quick fallback when DB has no default.
# Outcome: Use database default if available, otherwise fall back to config default
config_default = project_service.default_project
db_default = await project_service.repository.get_default_project()
default_project_name = db_default.name if db_default else config_defaultSimilar improvement needed for Testing & Coverage
|
Fixes #397 (basic-memory-cloud issue)
Related: basicmachines-co/basic-memory-cloud#397
Problem
In cloud mode, when a user sets a different project as default and then tries to delete the
mainproject, they receive a 400 error even thoughmainis no longer the default.Root Cause
State synchronization mismatch between config file and database:
remove_projectandget_default_projectendpoints read fromProjectService.default_projectpropertymainis default even after database is updatedThis issue only affects cloud mode because:
Solution
Updated v1 API endpoints to check database first, then fall back to config:
remove_project: Checkdb_defaultbefore blocking deletionget_default_project: Returndb_defaultif availableThis maintains backwards compatibility:
Note: v2 API already uses database correctly and doesn't have this bug.
Testing
Existing tests pass - the logic change is backwards compatible:
Manual testing needed in cloud environment to verify the fix.