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

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.

@SoloJacobs

Copy link
Copy Markdown
Contributor

@holger-waschke Could you have a look at this PR? Does it make sense?

@holger-waschke

Copy link
Copy Markdown
Contributor

@holger-waschke Could you have a look at this PR? Does it make sense?

I think this is a useful enhancement to the existing Jira notifier behavior.

Currently, updating an issue replaces the complete  labels  array, which can unintentionally remove labels added manually or by Jira automation.

Being able to omit  labels  from update requests avoids that problem.
The object-form configuration is slightly more verbose, but it seems reasonable because it is opt-in and the existing list syntax remains supported with unchanged behavior:

summary:
  enable_update: true
description:
  enable_update: true
labels:
  enable_update: false
  values:
    - alertmanager

With this configuration, Alertmanager still adds its labels when creating the issue, but preserves the issue’s existing labels on subsequent updates.

The PR now needs rebasing because its tests no longer compile against current  main , although the implementation itself applies cleanly.

@Drenovik

Copy link
Copy Markdown
Author

Thanks @holger-waschke and @SoloJacobs for taking a look.

Happy to rebase — just want to check first: is the rebase expected from me, or is there something on your end before that? Also want to make sure it's not for nothing — it took a while to get reviewed, and in that gap main moved on and the branch drifted out of sync, which is why it needs rebasing now. If we can agree here that this is good to merge, I'll rebase right away so we don't end up back in the same spot.

Also, #5443 is a direct extension of this one (adds update_mode: replace|merge on top of enable_update). Would it make sense to review/merge both together, or should I rebase #5443 too right now rather than let it go stale and get closed?

@SoloJacobs

Copy link
Copy Markdown
Contributor

Hi @Drenovik ,

my plan is to give this a thorough review, and then it is hopefully ready to land. We just have a lot to do within the project. So, no action required on your side.

Kind regards

@SoloJacobs

Copy link
Copy Markdown
Contributor

And for your second PR: I have really not looked at that feature yet. We also need the sign-off from other maintainers here, and there is a chance we might reject it. So, keep it separate from this one.

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.

4 participants