Skip to content

Improve Jira connection error messages for better user experience#370

Merged
kkaarreell merged 1 commit into
mainfrom
ks_jira_retries
Jun 2, 2026
Merged

Improve Jira connection error messages for better user experience#370
kkaarreell merged 1 commit into
mainfrom
ks_jira_retries

Conversation

@kkaarreell

@kkaarreell kkaarreell commented Jun 2, 2026

Copy link
Copy Markdown
Collaborator

Replace verbose HTML error dumps with concise, actionable error messages when Jira connection fails. The new error handling:

  • Extracts HTTP status codes from JIRAError exceptions
  • Provides specific guidance for common errors (401/403/404)
  • Shows authentication type and URL without HTML page dumps
  • Limits error text to 200 chars for unknown errors

This significantly improves debugging experience by showing users exactly what went wrong instead of 500+ lines of HTML.

🤖 Generated with Claude Code

Summary by Sourcery

Improve Jira connection error handling to provide concise, user-friendly feedback when authentication or connectivity fails.

Bug Fixes:

  • Clarify Jira authentication failures by mapping HTTP status codes (401/403/404) to specific, actionable error messages instead of generic exceptions.

Enhancements:

  • Replace verbose HTML error dumps from Jira connection failures with short, context-rich messages that include authentication type, URL, and truncated error details for unknown errors.

Replace verbose HTML error dumps with concise, actionable error messages
when Jira connection fails. The new error handling:
- Extracts HTTP status codes from JIRAError exceptions
- Provides specific guidance for common errors (401/403/404)
- Shows authentication type and URL without HTML page dumps
- Limits error text to 200 chars for unknown errors

This significantly improves debugging experience by showing users
exactly what went wrong instead of 500+ lines of HTML.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@kkaarreell kkaarreell self-assigned this Jun 2, 2026
@sourcery-ai

sourcery-ai Bot commented Jun 2, 2026

Copy link
Copy Markdown

Reviewer's Guide

Refines Jira connection error handling to provide concise, status-aware, and context-rich messages instead of generic authentication failures and verbose HTML dumps, while keeping the connection logic otherwise unchanged.

Sequence diagram for improved Jira connection error handling

sequenceDiagram
    actor User
    participant JiraService as JiraConnection
    participant JiraAPI as jira.JIRA

    User->>JiraService: get_connection()
    JiraService->>JiraAPI: jira.JIRA(url, auth, options)
    JiraService->>JiraAPI: myself()

    alt [connection succeeds]
        JiraAPI-->>JiraService: user info
        JiraService-->>User: JIRA instance
    else jira.JIRAError with status_code 401
        JiraAPI--xJiraService: jira.JIRAError(status_code=401)
        JiraService-->>User: Exception(Authentication failed, check auth_type)
    else jira.JIRAError with status_code 403
        JiraAPI--xJiraService: jira.JIRAError(status_code=403)
        JiraService-->>User: Exception(Access forbidden, insufficient permissions)
    else jira.JIRAError with status_code 404
        JiraAPI--xJiraService: jira.JIRAError(status_code=404)
        JiraService-->>User: Exception(Jira instance not found, check URL)
    else jira.JIRAError with other or no status_code
        JiraAPI--xJiraService: jira.JIRAError
        JiraService-->>User: Exception(HTTP status specific or truncated error, with auth_type and URL)
    end
Loading

File-Level Changes

Change Details Files
Improve Jira connection error handling with HTTP status awareness and concise, contextual messages.
  • Introduce an auth_type variable computed before connection attempts for use in error messages.
  • Wrap Jira connection creation and verification in a try/except jira.JIRAError block that builds human-readable error messages instead of surfacing raw HTML.
  • Map common HTTP status codes (401, 403, 404) to specific, user-focused guidance about credentials, permissions, and URL correctness.
  • Provide a generic HTTP error message for other status codes and a truncated (200 chars) fallback message when no status code is available, always including Jira URL and authentication type where relevant.
  • Replace the previous generic 'Wrong auth' exception message with richer, actionable error text while preserving the original exception as the cause.
newa/services/jira_connection.py

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hey - I've left some high level feedback:

  • In the jira.JIRAError handling, consider including the auth_type in the 401/403 branches as well so users can immediately see which authentication mechanism failed without having to infer it from the deployment type.
  • Right now the original jira.JIRAError details are only exposed via exception chaining; if these HTML-heavy responses are still useful for deeper debugging, consider logging the raw error (at debug level) before raising the cleaned-up message.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- In the `jira.JIRAError` handling, consider including the `auth_type` in the 401/403 branches as well so users can immediately see which authentication mechanism failed without having to infer it from the deployment type.
- Right now the original `jira.JIRAError` details are only exposed via exception chaining; if these HTML-heavy responses are still useful for deeper debugging, consider logging the raw error (at debug level) before raising the cleaned-up message.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@kkaarreell kkaarreell merged commit e28eede into main Jun 2, 2026
16 checks passed
@kkaarreell kkaarreell deleted the ks_jira_retries branch June 2, 2026 12:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant