Summary
bm project add --cloud --local-path <path under a file> persists a config entry whose path cannot be loaded. Every subsequent bm command then dies with "failed to load config" — including the commands a user would reach for to undo it.
Found while implementing #1414 (PR #1440), flagged rather than fixed there because it is a different class from the recovery-path findings that PR was addressing.
Cause
The config save happens before the mkdir. So an invalid --local-path is written to disk first, and the failure that would have revealed it comes second — by which time the bad entry is already persisted.
Why it matters more than it looks
The failure is not scoped to the project that was added. A config that cannot load takes out the whole CLI, so the user has no in-tool route back: they cannot list projects, cannot remove the bad one, and cannot inspect what happened. The recovery is a manual edit of the config file, which the error message does not mention.
Direction
Validate the path before persisting anything, or persist only after the directory exists. Given the ordering is the defect, the second is likely simpler and also fixes any other post-save step that can fail on a path.
Worth checking at the same time:
- Whether config loading should degrade rather than hard-fail on one bad entry, so a single unusable project cannot make the tool unusable. That is arguably the deeper fix — the ordering bug is one way to reach the state, and a hand-edited config is another.
- Whether the same save-before-validate ordering exists on other paths that write config entries.
Verify whether this is pre-existing
PR #1440 restructured the post-persist error handling in this command. Establish whether the save-before-mkdir ordering predates that change — the reporter's reading is that it does, but it should be confirmed against main before the issue is scoped, since that determines whether this is a regression to fix urgently or a long-standing trap.
Summary
bm project add --cloud --local-path <path under a file>persists a config entry whose path cannot be loaded. Every subsequentbmcommand then dies with "failed to load config" — including the commands a user would reach for to undo it.Found while implementing #1414 (PR #1440), flagged rather than fixed there because it is a different class from the recovery-path findings that PR was addressing.
Cause
The config save happens before the
mkdir. So an invalid--local-pathis written to disk first, and the failure that would have revealed it comes second — by which time the bad entry is already persisted.Why it matters more than it looks
The failure is not scoped to the project that was added. A config that cannot load takes out the whole CLI, so the user has no in-tool route back: they cannot list projects, cannot remove the bad one, and cannot inspect what happened. The recovery is a manual edit of the config file, which the error message does not mention.
Direction
Validate the path before persisting anything, or persist only after the directory exists. Given the ordering is the defect, the second is likely simpler and also fixes any other post-save step that can fail on a path.
Worth checking at the same time:
Verify whether this is pre-existing
PR #1440 restructured the post-persist error handling in this command. Establish whether the save-before-mkdir ordering predates that change — the reporter's reading is that it does, but it should be confirmed against
mainbefore the issue is scoped, since that determines whether this is a regression to fix urgently or a long-standing trap.