Skip to content

jira: allow disabling label updates via labels.enable_update - #5442

Open
Drenovik wants to merge 1 commit into
prometheus:mainfrom
Drenovik:jira-labels-enable-update
Open

jira: allow disabling label updates via labels.enable_update#5442
Drenovik wants to merge 1 commit into
prometheus:mainfrom
Drenovik:jira-labels-enable-update

Conversation

@Drenovik

Copy link
Copy Markdown

What changed

  • notify/jira/config.go: JiraLabelsConfig gains EnableUpdate *bool and Values []string;
    a custom UnmarshalYAML accepts both the legacy labels: [a, b] list and a new object
    form labels: { enable_update: false, values: [...] }. EnableUpdateValue() defaults
    to true when unset (matches the enable_update pattern already used for
    summary/description in Jira Integration: Allow configuring issue update via parameter #4621).
  • notify/jira/jira.go: on issue update (HTTP PUT), if enable_update resolves to false,
    Fields.Labels is set to nil (not an empty slice) so the JSON labels key is omitted
    entirely - manually added / automation-added Jira labels are left untouched. Issue
    creation (POST) is unaffected and always sets labels.
  • Docs (docs/configuration.md) and CHANGELOG.md updated.

Why

Every notifier PUT today fully replaces fields.labels, silently wiping labels added by
a human or by Jira automation after issue creation - a known migration issue coming
from jiralert (which never updated labels post-create). This mirrors the existing
enable_update pattern for summary/description (#4621) rather than inventing a new
mechanism.

Backward compatibility

The legacy labels: [a, b] YAML list keeps working unchanged - enable_update defaults
to true, so existing configs see identical behavior (labels are still replaced on
every update, as before). Only configs that opt into the new object form and
explicitly set enable_update: false see a behavior change.

Testing

  • Unit tests: go test ./notify/jira/ ./config/ -count=1 - new/updated cases cover:
    legacy list unmarshal, object-form unmarshal (both flag values), create always sets
    labels, update with enable_update true (labels replaced) and false (labels omitted
    from the request body).
  • Config loading: amtool check-config against a new fixture using the legacy labels
    list form - confirms no regression in config parsing for existing users.
  • Manual end-to-end testing against a private Jira Data Center instance: created an
    issue, manually added a label unrelated to the Alertmanager config, then triggered
    an update. With enable_update unset (legacy default), the manually added label was
    removed (expected baseline, matches current released behavior). With
    enable_update: false, the manually added label survived the update.

Pull Request Checklist

Please check all the applicable boxes.

  • Please list all open issue(s) discussed with maintainers related to this change
  • Is this a new Receiver integration?
    • N/A - existing jira_configs receiver, not a new receiver type
  • Is this a bugfix?
    • N/A - this is not a bugfix
  • Is this a new feature?
    • I have added tests that test the new feature's functionality
  • Does this change affect performance?
    • N/A - no performance-sensitive path touched
  • Is this a breaking change?
    • My changes do not break the existing cluster messages
    • My changes do not break the existing api
  • I have added/updated the required documentation
  • I have signed-off my commits
  • I will follow best practices for contributing to this project

Which user-facing changes does this PR introduce?

[ENHANCEMENT] jira: Allow disabling label updates on existing issues via labels.enable_update (legacy labels list unchanged).

Support object-form labels with enable_update while keeping the legacy
YAML list fully compatible. When enable_update is false, omit labels on
PUT so manual/automation labels are not wiped (create still sets labels).

Signed-off-by: Drenovik <forget.alphabet071@slmails.com>
@coderabbitai

coderabbitai Bot commented Aug 11, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 47facd0f-0328-4bb9-90e8-1f3c897b05f2

📥 Commits

Reviewing files that changed from the base of the PR and between 8d7515a and d4459b0.

📒 Files selected for processing (7)
  • CHANGELOG.md
  • config/config_test.go
  • config/testdata/conf.jira-legacy-labels.yml
  • docs/configuration.md
  • notify/jira/config.go
  • notify/jira/jira.go
  • notify/jira/jira_test.go

📝 Walkthrough

Walkthrough

Jira label configuration now supports legacy lists and an object form with values and enable_update. Label updates can be disabled for existing issues while labels remain included during issue creation. Tests and documentation cover parsing and request behavior.

Changes

Jira label update control

Layer / File(s) Summary
Jira label configuration contract
notify/jira/config.go, config/testdata/conf.jira-legacy-labels.yml, config/config_test.go
JiraLabelsConfig stores label values and the optional update flag. YAML parsing accepts both list and object forms.
Jira label update behavior
notify/jira/jira.go
The notifier uses Labels.Values and omits labels from existing-issue updates when updates are disabled. Creation requests still include labels.
Label behavior validation and documentation
notify/jira/jira_test.go, docs/configuration.md, CHANGELOG.md
Tests cover YAML parsing, creation, and existing-issue updates. Documentation and the changelog describe the new configuration forms and behavior.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant JiraNotifier
  participant JiraLabelsConfig
  participant JiraAPI
  JiraNotifier->>JiraLabelsConfig: read Values and EnableUpdateValue()
  alt creating an issue
    JiraNotifier->>JiraAPI: send creation request with labels
  else updating an existing issue
    JiraNotifier->>JiraAPI: send update request without labels when updates are disabled
  end
Loading
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the Jira notifier change and the new labels.enable_update option.
Description check ✅ Passed The description explains the change, rationale, compatibility, testing, documentation, release notes, and checklist status.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@Drenovik

Copy link
Copy Markdown
Author

CodeRabbit’s Docstring Coverage warning is about the new JiraLabelsConfig.EnableUpdateValue method, which has no godoc — matching the existing JiraFieldConfig.EnableUpdateValue in the same file.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants