Fix empty auth token on all update subcommands - #8
Merged
Conversation
--debug omitted the Authorization header entirely, so a request sent with an empty bearer token looked identical to a correctly authenticated one. Print the scheme and credential length instead of hiding the header. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KJEaYFr7zMmqbF6j1mZFT3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Every
updatesubcommand in the CLI sends an empty bearer token and fails with a 401:The token is fine — the same token, URL, and body succeed via
curl. The request goesout as
Authorization: Bearerwith nothing after it.skipAuth()incmd/root.godecides which commands may run unauthenticated by matchingthe bare command name against a reserved list, but it checked every command in the
chain, at any depth:
webex calling workspaces updateends inupdate, which collides with the top-levelself-update command
webex update.PersistentPreRunEtherefore returned early beforereaching
config.SetToken(...), and the request was built with no credentials.Affected: all 38
updatesubcommands acrosscalling,cc,device,meetings,messaging, andadmin, pluswebex cc agents loginandwebex cc agents logout(same collision, against top-level
login/logout). Present since the initial commit;not a regression.
createanddeletewere never affected — neither name collides — which is why readsand creates worked and made this look like a scope problem.
Two things hid the cause:
--debugredacts theAuthorizationheader, so the emptyvalue was invisible in exactly the output used to debug it, and a 401 reads as a
token/scope failure rather than a routing bug.
Fix
skipAuth()now resolves the top-level ancestor and matches only on that name, so anested API subcommand named
updateno longer inherits the exemption.auth set-orgkeeps its existing carve-out.
completionand cobra's hidden__complete/__completeNoDesc, which hadthe inverse bug — they demanded a token they never use, so shell completion failed for
unauthenticated users.
--debug(and--dry-run) now print theAuthorizationheader asBearer <106 chars>instead of omitting it. Hiding the header entirely is what madethis bug invisible: an empty token rendered identically to a valid one. The empty case
now reads
Bearer <0 chars>. No credential material is printed.webex auth token, which prints the resolved access token, refreshing it first ifexpired. This is what made the diagnosis possible (it enables reproducing any CLI call
with
curl), and it is carved out ofskipAuthalongsideset-orgsince it needs thetoken resolved. Happy to split this into its own PR if you'd rather keep the fix alone.
Verification
Against a live org, using the built binary:
workspaces createworkspaces updateworkspaces deleteworkspaces list/getFull create → update → delete lifecycle passes, and all test resources were cleaned up.
Commands that must not require auth (
version,config get,completion,--help)still run without a token;
auth statusand the read paths still resolve one.go buildandgo vet ./...are clean.cc agents login/logoutare fixed by the same change but were verified by readingthe code only — exercising them changes live agent state.
🤖 Generated with Claude Code
https://claude.ai/code/session_01KJEaYFr7zMmqbF6j1mZFT3