Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

Empty `AuthToken` Causes Cryptic JWT Parse Error

オープン 初心者向け
#551 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
86/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
go

調査の方向性

pkg/connectors/microcks_client.go の refreshAuthToken から開始し、そのエラーがどのように NewClient と CLI に到達するかを追跡してください。設定されたアクセストークンを消去した後の空の AuthToken のケースを再現し、ユーザーが JWT のパースエラーではなく、想定される未認証メッセージを受け取ることを確認してください。

索引モデルが issue の本文から書いたものです。

説明

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
}
How to Reproduce
  1. Log in, then selectively clear just the access token from the config:
    # Edit ~/.config/microcks/config and set auth-token to empty string
    microcks service list  # → "token is malformed: token contains an invalid number of segments"
    
  2. Compare with the expected UX:
    # Expected
    Error: not authenticated. Run `microcks login` first.
    
Diagram
flowchart TD
    A["NewClient() called"] --> B["ReadLocalConfig()"]
    B --> C["configCtx.User.AuthToken = ''"]
    C --> D["refreshAuthToken()"]

    D --> E{"c.RefreshToken == ''?"}
    E -- "no — refresh token exists" --> F["jwt.ParseUnverified('' , &claims)"]
    F --> G["jwt.ErrTokenMalformed ← cryptic error"]
    G --> H["NewClient returns error to caller"]
    H --> I["CLI prints: 'token is malformed: token contains an invalid\nnumber of segments' "]

    E -- "yes — no refresh token" --> J["return nil (no-op) "]

    subgraph Fix
        D --> K{"c.AuthToken == ''?"}
        K -- "yes" --> L["return ErrNotAuthenticated "]
        K -- "no" --> F
    end

    style G fill:#e74c3c,color:#fff
    style I fill:#e74c3c,color:#fff
    style J fill:#2ecc71,color:#fff
    style L fill:#2ecc71,color:#fff
Expected behavior

No response

Actual behavior

No response

How to Reproduce?

No response

Microcks version or git rev

No response

Install method (docker-compose, helm chart, operator, docker-desktop extension,...)

No response

Additional information

No response

主要言語
Go
スター
52
フォーク
67
平均マージ
3日 23時間
マージ済み PR(30日)
23

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

microcks/microcks-cli のほかの issue

microcks/microcks-cli の issue をすべて見る

似ている issue

Go の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。