Skip to content

Invalid or expired API token is reported as "No issues found" instead of an authentication error #153

Closed

Description

@f3rdy

Observed

With an invalid, expired or revoked API token, budjira search prints

⚠ No issues found

and exits successfully. Nothing hints at the credentials. The same applies to any command that only reads issues through search (lists, aliases built on search). A stale api_token_ref (for example one pointing at a password-store entry that still holds a rotated-out token) looks exactly like an empty project.

Root cause (measured against Jira Cloud)

Jira Cloud treats failed Basic-auth credentials as an anonymous request on several endpoints instead of rejecting them:

Endpoint Invalid token No credentials at all
GET /rest/api/3/myself 401 "Client must be authenticated to access this resource." 401
GET /rest/api/3/search/jql?jql=project=KEY 200 {"issues":[],"isLast":true} 200, same body
GET /rest/api/2/serverInfo 200 200

So:

  • JiraClient construction succeeds (the jira library only touches serverInfo).
  • IssueService.search never sees a JIRAError — it gets a valid, empty result. Its 401/403 handling can't fire.

Proposal

Verify the credentials explicitly instead of trusting a successful response:

  • Option A — on connect: call GET /rest/api/3/myself once in JiraClient.__init__ (or lazily on first use) and raise AuthenticationError on 401. Costs one request per invocation.
  • Option B — only when it matters: when a search returns zero issues, call /myself; on 401 raise AuthenticationError instead of printing "No issues found". No extra request on the happy path.
  • budjira connect test (if present) should use /myself too, not an endpoint that answers anonymously.

The error should name the connection and the token source (api_token_ref / env var / stored credential) without printing the token.

Acceptance

  • With an invalid token, budjira search "<jql>" exits non-zero with an authentication error naming the connection and the token source.
  • With a valid token and a JQL that genuinely matches nothing, "No issues found" is unchanged.
  • Unit tests cover both cases (200-empty + /myself 401 → error; 200-empty + /myself 200 → "No issues found").

Activity

  1. added
    bug
    priority:medium
    on Nov 3, 2026
  2. f3rdy commented on Nov 3, 2026

    @f3rdy
    ContributorAuthor

    Released in v1.38.1 (PR #154). Verified live: a revoked token now fails with an authentication error naming the connection, user and token source; with a valid token an empty project still reports "No issues found".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugpriority:medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions