Sanitize rendered issue descriptions to prevent Jira Cloud auto-linking#342
Merged
Conversation
Reviewer's guide (collapsed on small PRs)Reviewer's GuideApplies Jira-specific description sanitization when creating or updating issues so that rendered descriptions (especially version-like strings) are pre-processed via the existing Jira formatting helper before being sent to Jira Cloud, preventing unwanted auto-linking behavior. Sequence diagram for sanitized Jira issue creation flowsequenceDiagram
actor User
participant CLI
participant JiraService
participant JiraCloud
User->>CLI: Invoke create_issue with raw description
CLI->>JiraService: create_issue(description, use_newa_id, fields, links)
JiraService->>JiraService: _format_for_jira(description)
alt use_newa_id is True
JiraService->>JiraService: newa_id(action)
JiraService->>JiraService: _format_for_jira(newa_id)
JiraService->>JiraService: Prepend formatted newa_id to sanitized description
end
JiraService->>JiraCloud: POST create issue with sanitized description
JiraCloud-->>JiraService: Created issue
JiraService-->>CLI: Return Issue
CLI-->>User: Show created issue key
Sequence diagram for sanitized Jira issue update flowsequenceDiagram
actor User
participant CLI
participant JiraService
participant JiraCloud
User->>CLI: Invoke update_issue with raw description
CLI->>JiraService: update_issue(issue, description)
JiraService->>JiraService: _format_for_jira(description)
JiraService->>JiraService: get_details(issue)
JiraService->>JiraService: Read current_description from issue_details
JiraService->>JiraCloud: PUT update issue with sanitized description
JiraCloud-->>JiraService: Updated issue
JiraService-->>CLI: Return success flag
CLI-->>User: Confirm description updated
Class diagram for JiraService description sanitization changesclassDiagram
class JiraService {
+create_issue(summary, description, action, use_newa_id, fields, links) Issue
+update_issue(issue, description) bool
+get_details(issue) Issue
-_format_for_jira(text) str
-newa_id(action) str
}
class Issue {
+key str
+fields IssueFields
}
class IssueFields {
+description str
}
JiraService --> Issue
Issue --> IssueFields
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- Consider keeping
_render_action_fieldsfree of side-effectful dependencies by passing in asanitize_commentcallable (or pre-sanitizing the description at a higher layer) instead of reaching intoctxto get a Jira connection inside the helper. - If Jira Cloud auto-linking is also undesirable in other text fields (e.g., summary or any custom text fields), it may be worth centralizing the sanitization logic at a single boundary where all outbound Jira text is processed consistently.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Consider keeping `_render_action_fields` free of side-effectful dependencies by passing in a `sanitize_comment` callable (or pre-sanitizing the description at a higher layer) instead of reaching into `ctx` to get a Jira connection inside the helper.
- If Jira Cloud auto-linking is also undesirable in other text fields (e.g., summary or any custom text fields), it may be worth centralizing the sanitization logic at a single boundary where all outbound Jira text is processed consistently.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
d6ce0a1 to
48272ba
Compare
Collaborator
Author
|
@sourcery-ai review |
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- In both create_issue and update_issue, description is passed directly into _format_for_jira; if description can be None in any call path, consider normalizing it to an empty string or handling None inside _format_for_jira to avoid potential runtime errors.
- In create_issue, description is sanitized before potentially prefixing the NEWA ID, but the NEWA ID itself is sanitized separately; consider consolidating the formatting logic (e.g., build the full description string first, then pass it once through _format_for_jira) to keep behavior consistent and reduce the chance of discrepancies if the sanitizer changes.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- In both create_issue and update_issue, description is passed directly into _format_for_jira; if description can be None in any call path, consider normalizing it to an empty string or handling None inside _format_for_jira to avoid potential runtime errors.
- In create_issue, description is sanitized before potentially prefixing the NEWA ID, but the NEWA ID itself is sanitized separately; consider consolidating the formatting logic (e.g., build the full description string first, then pass it once through _format_for_jira) to keep behavior consistent and reduce the chance of discrepancies if the sanitizer changes.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
…thods Sanitize description text before passing to Jira API to prevent conflicts with Jira's auto-linking syntax. This ensures user-provided descriptions are properly formatted for Jira Cloud. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
48272ba to
c4aa63e
Compare
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.
When rendering Jira issue descriptions from templates, the rendered text (containing strings like RHEL-9.8.0) was not being sanitized for Jira Cloud. This caused Jira to incorrectly auto-link these strings as issue references.
This fix applies the sanitize_comment() method to the rendered description, which replaces regular hyphens with non-breaking hyphens (U+2011) for Jira Cloud instances. This preserves the visual appearance while preventing unwanted auto-linking behavior.
🤖 Generated with Claude Code
Summary by Sourcery
Bug Fixes: