Repository navigation
fix(client): detect rejected credentials instead of reporting empty results - #154
Merged
Merged
Conversation
…esults Jira Cloud answers most reads anonymously when Basic auth fails: search/jql returns 200 with no issues, issues return 404, project search returns an empty list. Only endpoints that need a user, such as /myself, return 401. An expired or revoked token therefore looked like an empty project. JiraClient now verifies the credentials via /myself right after connecting and raises an AuthenticationError naming the connection, the user and the token source (never the token). One extra request per invocation; serverInfo cannot be dropped instead, the jira library derives the deployment type and version from it. Closes #153
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.
Closes #153
Problem
Jira Cloud answers most reads anonymously when Basic auth fails (measured):
GET /rest/api/3/myselfGET /rest/api/3/search/jqlGET /rest/api/2/serverInfoGET /rest/api/3/issue/KEYGET /rest/api/3/project/searchSo an expired or revoked token looked like an empty project (
search), a missing issue (show) or an instance without projects (project list).Fix
JiraClientverifies the credentials via/myselfright after connecting:AuthenticationErrornaming the connection, the user and the token source (api_token_ref/ env var / stored credential) — never the token.PermissionError; anything else →JiraAPIError.Central check rather than per command, because every read path is affected.
Cost: one extra request per invocation (~260 ms measured against Jira Cloud).
serverInfocannot be dropped in exchange — the jira library derives the deployment type (_is_cloud) and version from it.connect testalready verified viacurrent_user()and is unchanged.Verification
searchexit 1 with the authentication error instead of "No issues found"; a valid token with no matches still prints "No issues found". The rejection test fails without the fix.