fix: (cloud) CLI cloud commands now use API key when configured#698
fix: (cloud) CLI cloud commands now use API key when configured#698phernandez merged 1 commit intomainfrom
Conversation
get_authenticated_headers() only checked OAuth tokens, ignoring config.cloud_api_key entirely. This meant all CLI cloud commands (upload, status, snapshot, restore, etc.) failed for API-key-only users — even though MCP tools worked fine via _resolve_cloud_token(). Now mirrors the same credential priority: API key first, OAuth fallback. Fixes: bm cloud upload --project returning "project does not exist" when authenticated with bmc_* API key. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: phernandez <paul@basicmachines.co>
|
Claude finished @phernandez's task in 1m 3s —— View job PR Review: fix(cloud): CLI cloud commands now use API key when configured
SummaryClean, focused fix. The root cause is clear: Code Quality & Standards Checklist
Code Review
The implementation correctly mirrors # async_client.py (reference)
token = config.cloud_api_key
if token:
return token
# ... OAuth fallback
# api_client.py (this PR)
api_key = config_manager.config.cloud_api_key
if api_key:
return {"Authorization": f"Bearer {api_key}"}
# ... OAuth fallbackThe section headers ( Minor observation (not a blocker): Tests
Both tests follow the existing fixture/mock patterns in the file. Architecture & Security
VerdictLGTM. This is a correct, minimal fix with good test coverage and no regressions to the OAuth path. Ready to merge. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c125c7a79f
ℹ️ 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".
| if api_key: | ||
| return {"Authorization": f"Bearer {api_key}"} |
There was a problem hiding this comment.
Honor explicit OAuth auth before API-key fallback
The unconditional API-key early return means get_authenticated_headers(auth=...) ignores the caller-provided OAuth context whenever cloud_api_key is set. In practice this breaks OAuth recovery flows (for example the post-login health check in core_commands.py) when a saved API key is stale or mistyped, because requests keep using the bad key even after a successful OAuth login. This regression was introduced by the new priority logic and can block users from recovering via bm cloud login.
Useful? React with 👍 / 👎.
Summary
get_authenticated_headers()inapi_client.pyonly checked OAuth tokens, ignoringconfig.cloud_api_keyentirelyupload,status,snapshot,restore, etc.) failed for API-key-only users — even though MCP tools worked fine via_resolve_cloud_token()bm cloud upload --projectreturning "project does not exist" when authenticated withbmc_*API keyTest plan
test_make_api_request_prefers_api_key_over_oauth— verifies API key is used when configured, no OAuth token neededtest_make_api_request_falls_back_to_oauth_when_no_api_key— verifies OAuth still works when no API key is setbm cloud set-key bmc_...thenbm cloud upload /path --project mainshould workbm cloud statuswith API key only (no OAuth) should work🤖 Generated with Claude Code