basic-memory icon indicating copy to clipboard operation
basic-memory copied to clipboard

[BUG] bm project list shows empty table while bm project add reports the project already exists (configured/cloud-mode project never rendered)

Open groksrc opened this issue 5 months ago • 1 comments

Summary

bm project list renders an empty table even when a project exists in config.json (and in the local DB). The same project is simultaneously reported as already existing by bm project add, so the two commands disagree about whether the project exists.

Reproduction

$ bm project list
                              Basic Memory Projects
┏━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━━┳━━━━━━━━━━━┳━━━━━┳━━━━━━┳━━━━━━━━━┓
┃ Name ┃ Local Path ┃ Cloud Path ┃ Workspace ┃ CLI Route ┃ MCP ┃ Sync ┃ Default ┃
┡━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━━╇━━━━━━━━━━━╇━━━━━╇━━━━━━╇━━━━━━━━━┩
└──────┴────────────┴────────────┴───────────┴───────────┴─────┴──────┴─────────┘

$ bm project add main ~/basic-memory
Error adding project: Project 'main' already exists

So add says main exists, but list shows nothing.

Environment

  • basic-memory 0.22.0
  • macOS (Apple Silicon), Homebrew install
  • XDG config: ~/.config/basic-memory/config.json, env: "dev"
  • No cloud credentials configured on this machine

What's actually in state

~/.config/basic-memory/config.json:

"projects": {
  "main": {
    "path": "",
    "mode": "cloud",
    "workspace_id": null,
    "local_sync_path": null,
    ...
  }
},
"default_project": "main"

Local DB (~/.config/basic-memory/memory.db), project table:

3|main|main|        <- name=main, permalink=main, path=''

So main is present both in config.projects and in the local DB — it is genuinely not missing. It is mode: cloud with an empty path and no cloud credentials present.

Root cause

In src/basic_memory/cli/commands/project.py, list_projects() builds the table rows (row_names_by_key → sorted_row_keys → project_rows) exclusively from live API query results — the local API list and the per-workspace cloud lists:

# cloud results populate row_names_by_key
for cloud_workspace, cloud_result in cloud_results:
    ...
    row_names_by_key[row_key] = project.name

# local results populate row_names_by_key
for permalink, project in local_projects_by_permalink.items():
    if permalink not in cloud_permalinks:
        row_names_by_key[(None, permalink)] = project.name

config.projects is consulted only to enrich rows that already exist (configured_names_by_permalink is used for the attached-row lookup), but a configured project never creates a row on its own.

The result: a project that is in config.projects but is not surfaced by either query becomes invisible. That is exactly what happens here — main is mode: cloud, so:

  • the cloud branch is skipped because _has_cloud_credentials(config) is false (no creds on this machine), and
  • the local query does not surface a cloud-mode project,

so row_names_by_key ends up empty and the table has zero rows.

Meanwhile bm project add checks the server/DB, finds main, and reports "already exists". The two commands consult different sources of truth.

Expected behavior

bm project list should never show an empty table when config.projects is non-empty. A configured project should appear as a row even when it isn't returned by the live local/cloud queries (e.g. a cloud-mode project on a machine without cloud credentials). At minimum, list should fall back to config.projects for row keys and indicate why a configured project can't be fully resolved (e.g. "cloud, no credentials"), rather than silently hiding it.

Possible fix direction

Seed row_names_by_key from configured_names_by_permalink (config.projects) in addition to the local/cloud query results, so configured-but-unqueried projects still render. Cloud-mode entries with no credentials could show cli_route = cloud and an empty cloud path plus a hint to run bm cloud login.

Related

  • #974 (config/DB inconsistency on fresh project add) — related but distinct: there the project is missing from the DB; here main is present in the DB and still not listed.
  • #949 (empty path in config) — same empty-path config entry shows up here.

groksrc avatar Jun 15 '26 14:06 groksrc

Claude finished @groksrc's task in 5m 9s —— View job • Create PR ➔


Triage & Fix

Issue Classification: Bug — High priority, CLI component, Medium complexity

Root cause confirmed: list_projects() seeds row_names_by_key only from live API query results (local DB + cloud API). A mode: cloud project with no credentials active is skipped by both sources — the cloud branch is guarded by _has_cloud_credentials() and the local query doesn't surface cloud-mode-only projects — so row_names_by_key ends up empty and the table shows nothing.

bm project add checks the DB directly and finds the project, causing the contradiction.

Fix: Seed row_names_by_key from config.projects (via configured_names_by_permalink) as a fallback for any configured project not surfaced by the live queries. Add a hint message when cloud-mode projects are shown without credentials.

  • [x] Analyze issue and classify
  • [x] Read relevant source code
  • [x] Add triage labels (only "bug" exists in repo)
  • [x] Implement fix in list_projects() (seed row_names_by_key from config as fallback)
  • [x] Add regression test (test_project_list_shows_configured_cloud_project_without_credentials)
  • [ ] Run lint + type checks (tool permissions not available in this run)
  • [x] Commit ready — push needs maintainer approval

Changes made:

src/basic_memory/cli/commands/project.py — After building configured_names_by_permalink (~line 494), collect permalinks already covered by query results and seed row_names_by_key with any configured project not in that set. Also prints a one-line dim note when cloud-mode projects are shown without cloud credentials.

# Seed row_names_by_key from config.projects for any project not surfaced by
# the local or cloud queries.
existing_permalinks = {key[1] for key in row_names_by_key}
for permalink, project_name in configured_names_by_permalink.items():
    if permalink not in existing_permalinks:
        row_names_by_key[(None, permalink)] = project_name

tests/cli/test_project_list_and_ls.py — New regression test: config has main in cloud mode with empty path and no cloud_api_key; local API returns an empty project list; asserts the table shows main with cli_route=cloud, mcp_stdio=https, is_default=True, and the no-credentials hint in output.

Push blocked: The GitHub App token for this run doesn't have write access to the repository. The commit c3632ec is ready on branch claude/issue-1003-20260615-1434. A maintainer can push it with: git push origin claude/issue-1003-20260615-1434

claude[bot] avatar Jun 15 '26 14:06 claude[bot]