Repository navigation
Conversation
…g in place With update_message and post_updates_to_thread both set, every notification after the first edits the root message in place and posts the same content as a thread reply. The edit discards the original text: a group that fires and then resolves ends up as a resolved root message plus one identical resolved reply, and the firing notification is gone. Post a copy of the initial message as the first thread reply right after the root message is created, so the thread keeps the full history. Signed-off-by: Ilya Lukyanov <ilya@luk.moe>
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. 🧰 Additional context used📚 Code guidelines (1)No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository: prometheus/alertmanager/.coderabbit.yaml Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (4)
Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review. 📝 WalkthroughWalkthroughWhen Slack message updates and thread posting are both enabled, the notifier posts the initial message and then copies it as the first reply in its thread. Tests cover thread-copy retries, operation without a store, and firing and resolution sequences. ChangesSlack thread notifications
Priority: ➖ Normal Estimated code review effort: 2 (Simple) | ~10 minutes Severity of issue fixed: Medium Sequence Diagram(s)sequenceDiagram
participant Notifier as Slack notifier
participant Store as nflog store
participant Slack as Slack API
Notifier->>Slack: Post initial message
Slack-->>Notifier: Return post result and timestamp
Notifier->>Store: Check for stored thread identifiers
Store-->>Notifier: Return identifier availability
Notifier->>Slack: Post initial message as thread reply
Merge Risk: ⚪ Minimal · up to The initial notification is preserved as a thread reply when both options are enabled. Retry handling and existing notification modes remain intact; no actionable merge-blocking risk was identified. Merge after normal checks pass. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Docstring CoverageExplanation Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 3 files. (1 skipped: 1 unsupported.)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
SoloJacobs
left a comment
There was a problem hiding this comment.
Hmm, interesting. I guess the trade-off here is whether we want to send an additional http request here vs. how much nicer this new way is to read. You could probably achieve the same history by turning off update_message, I guess?
Yeah, exactly
Almost! What I'm trying to get is:
An alternative: we previously had an SNS -> Slack lambda that behaved like Wdyt? |
|
Hi @ilyaluk , Thanks for the write-up. During the maintainer meetup we have discussed this feature, and we decided that it makes the most sense to go with the ✅️ reaction. The reason is that the other maintainers maintain similar functionality inside their forks, and also I just think the feature is more transparent. This should be behind a different feature flag and document the reactions:write permission. Kind regards |
|
Hey @SoloJacobs, thanks for your consideration! Sounds good, will send a follow-up PR in the coming days. Do you think it would make sense to make reaction customizable (e.g. a |
|
Hi @ilyaluk , sorry I missed this message. Both are reasonable. I guess it would be good to have some validation for the emoji? Kind regards, Solomon |


With both
update_messageandpost_updates_to_threadset, the first notification for an alert group posts a message to the channel. Every later notification for that group edits that message in place and posts the same content as a reply in its thread.The in-place edit discards the original text, so for a group that fires once and then resolves, the channel ends up with the root message showing the resolved state and a single thread reply with exactly the same content, and the firing notification is gone. With more updates the loss is smaller, but the first state of the group still disappears from the thread.
This PR makes the first notification also post a copy of the initial message as the first reply in its own thread, right after the root message is created. Later notifications still edit the root and append replies, so the thread holds the full history: the original notification followed by each update. Nothing changes when only one of the two options is set.
If posting the copy fails, the notification fails and is retried, same as when a thread reply fails. The root message's
tsand channel are stored by then, so the retry goes through the update path and posts the reply to the existing thread instead of creating a new root message. Fallback behaviour on unrecoverable errors was left out, as discussed in the #5540 review.I could put this behind its own option if you prefer, but I'm afraid of complicating the Slack configuration too much.
Another alternative is to post the original text as a reply only right before the first update is sent to the thread. That avoids the odd look of a fresh message that immediately has a reply with the same content, but the reply's timestamp would then be the time of the first update rather than of the original notification, and the message content would need to be retrieved from the Slack API or stored in nflog.
Pull Request Checklist
Please check all the applicable boxes.
Which user-facing changes does this PR introduce?