Skip to content

Empty AuthToken Causes Cryptic JWT Parse Error - #552

Merged
yada merged 1 commit into
microcks:masterfrom
aniket866:fix/check-empty-token
Oct 28, 2026
Merged

yada merged 1 commit into
microcks:masterfrom
aniket866:fix/check-empty-token

Conversation

@aniket866

@aniket866 aniket866 commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Describe the bug

Description

refreshAuthToken in pkg/connectors/microcks_client.go calls
jwt.ParseUnverified(configCtx.User.AuthToken, &claims) without first checking
whether AuthToken is empty. After a fresh install, after logout --token-only,
or whenever the config exists but contains no token, AuthToken is "". The JWT
parser returns an error for the empty string, which propagates all the way up to
NewClient and then to the user as a low-level JWT error rather than a
human-readable "please run microcks login" message.

// microcks_client.go (refreshAuthToken)
if c.RefreshToken == "" {
    return nil  // ← correctly handles empty refresh token
}
// ... but AuthToken="" is never guarded:
_, _, err = parser.ParseUnverified(configCtx.User.AuthToken, &claims)
if err != nil {
    return err  // ← surfaces as "token is malformed: ..." to the user
}

Ai Disclosure: No ai is used to code these lines,

Closes #551

Signed-off-by: aniket866 <[email protected]>
@naitk2

naitk2 commented Sep 28, 2026

Copy link
Copy Markdown

check code if err != nil {
return err // ← surfaces as "token is malformed: ..." to the user

@yada yada added kind/bug Something isn't working component/connectors labels Oct 15, 2026

@Vaishnav88sk Vaishnav88sk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM 👍🏻

@yada

yada commented Oct 28, 2026

Copy link
Copy Markdown
Member

Verified the merge result (build, go vet, go test ./... pass). With a context holding a refresh token but an empty access token, service list fails on master with token contains an invalid number of segments (exit 20). With this PR it says not authenticated. Run microcks login first (exit 2).

Disclosure: this comment was drafted with AI assistance, and the results were run locally.

@yada yada left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Verified locally. Disclosure: AI-assisted verification.

@yada
yada merged commit 914c592 into microcks:master Oct 28, 2026
7 checks passed

This branch was successfully deployed

1 active deployment
Build — 7f42f603 Deployed Sep 28, 2026 by aniket866 via build-verify-package #743
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component/connectors kind/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Empty AuthToken Causes Cryptic JWT Parse Error

4 participants