Skip to content

fix(cli): show configured project in list when uncredentialed (#1003)#1010

Open
rudi193-cmd wants to merge 1 commit into
basicmachines-co:mainfrom
rudi193-cmd:fix/issue-1003-config-project-list
Open

fix(cli): show configured project in list when uncredentialed (#1003)#1010
rudi193-cmd wants to merge 1 commit into
basicmachines-co:mainfrom
rudi193-cmd:fix/issue-1003-config-project-list

Conversation

@rudi193-cmd

Copy link
Copy Markdown
Contributor

Summary

bm project list renders an empty table even when a project exists in config.json and the local DB, while bm project add reports the same project already exists — the two commands disagree about whether the project exists (#1003).

Root cause

In src/basic_memory/cli/commands/project.py, list_projects() seeds its table rows (row_names_by_key) exclusively from live query results:

  • the cloud branch, which is guarded by _has_cloud_credentials(config) and skipped when no credentials are present, and
  • the local query, which does not surface a mode: cloud project.

config.projects is consulted only to enrich rows that already exist (configured_names_by_permalink), never to create one. So a cloud-mode project with no cloud credentials on the machine is surfaced by neither query → empty table. Meanwhile bm project add reads the DB, finds the project, and reports "already exists".

Fix

Seed a local-keyed row from config.projects for any configured project not already surfaced by a query. The existing row-building logic already derives the correct display (cloud CLI route, https MCP) from the config entry.

The fallback is scoped to the local-inclusive view — it is skipped for a pure --cloud listing (no local_result) and for a --workspace-filtered view, since those are deliberately narrowed and configured local projects must not leak into them.

Test

Adds test_project_list_shows_configured_project_without_cloud_credentials to tests/cli/test_project_list_and_ls.py: a cloud-mode project in config with _has_cloud_credentials false and an empty local list now renders the project instead of an empty table. Verified the test fails on main (empty table → StopIteration) and passes with the fix.

Verification

  • tests/cli/test_project_list_and_ls.py — 14 passed
  • tests/cli (full) — 414 passed
  • ruff check + ruff format --check — clean
  • ty check on the changed file — clean

Fixes #1003

…achines-co#1003)

`bm project list` seeded its table rows only from live query results — the
cloud query (skipped when no credentials are present) and the local query.
`config.projects` was used only to enrich existing rows, never to create one,
so a cloud-mode project with no cloud credentials on the machine was surfaced
by neither query and rendered an empty table. Meanwhile `bm project add` reads
the DB and reports the same project already exists, so the two commands
disagreed about whether the project existed.

Seed a local-keyed row from `config.projects` for any configured project not
already surfaced, scoped to the local-inclusive view so a `--cloud` or
`--workspace`-filtered listing stays deliberately narrow. Adds a regression
test covering the cloud-mode-without-credentials case.

Fixes basicmachines-co#1003

Signed-off-by: rudi193-cmd <rudi193@gmail.com>
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

@phernandez

Copy link
Copy Markdown
Member

@codex review

@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: 59844d1224

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

# Constraint: only fill from config for the local-inclusive view. A pure
# --cloud listing (no local_result) or a --workspace-filtered view is
# deliberately scoped, so configured local projects must not leak into it.
if local_result is not None and not workspace_filter_requested:

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Keep config fallback out of --local listings

When the user runs bm project list --local after a project has been switched to cloud mode, the forced local query can legitimately return no row because set-cloud removes the local DB entry. This branch still seeds the cloud-mode config entry because local_result is non-None, so the --local listing shows a project that the local API did not return and later labels its CLI route as local (flag), making the flag no longer mean “show the local project list.” Gate this fallback to the default no-flag path (the uncredentialed mixed view) rather than all local-inclusive calls.

Useful? React with 👍 / 👎.

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.

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

2 participants