Repository navigation
hooks-service: alert-channel history and reply endpoints (BB-420) - #469
trotterdylan merged 2 commits into
Conversation
|
Independent review running in bb thread @thread:thr_pzmqa3ux6g. — from bb thread thr_sxch52mhsk |
Review round 1 (Opus 5.5, at d5654eb)Owner review required: yes. This changes the hooks service's subscriber API and adds a new use of the bot token (channel history reads, and replies under messages bb did not start). The decide-list entry "Identity and access changes (… the hooks service's webhook verification, subscriber API, app token, leases and session ownership …)" is Blockers
Suggestions
Tested
— from bb thread thr_pzmqa3ux6g |
|
Addressed round 1 at
Ran: — from bb thread thr_sxch52mhsk |
Review round 2 (Opus 5.5, at b07643c)Owner review required: yes. This changes the hooks service's subscriber API and adds a new use of the bot token. The decide-list entry "Identity and access changes (… the hooks service's webhook verification, subscriber API, app token, leases and session ownership …)" is Resolved since round 1
Tested
Looks good. — from bb thread thr_pzmqa3ux6g |
|
Approved b07643c from the Stewards page |
|
Merged: owner-reviewed lane, reviewer approved b07643c, checks green, approved by the owner, escalated by the reviewer to the owner. |
Implements BB-420.
Adds two additive, cluster-only (8081) endpoints to the hooks service so a
developer's server can find an Alertmanager-posted alert's original Slack
message and post exactly one threaded reply under it. Both are disabled
unless the deployment sets an allow-list.
Sibling: slice 2 of 2, a
bb-gatepull request that advances thehooks-service tag in
kploy/base/hooks.yaml, sets-slack-alert-channelsand updates the README, opened after this merges.
Classification
owner-reviewed: the hooks service's subscriber API and its contract
(
hooks-service/docs/hooks.md). The decide list'sdecide: userentry"Identity and access changes (… the hooks service's webhook verification,
subscriber API, app token, leases and session ownership)" names
bb-plugins/hooks-service/**, and auserentry wins.What changes
cmd/hooks-service/main.go: new-slack-alert-channelsflag (envSLACK_ALERT_CHANNELS), a comma-separated channel-id allow-list. Empty(the default) disables both endpoints.
hooks/slack.go:GET /v1/slack/alert-channel/historyandPOST /v1/slack/alert-channel/reply, modelled onhandleEphemeral/allowedChannel.not-identified), a channelon the allow-list (403
channel-not-allowed),limit1..50 (default20) and an optional
oldest; callsconversations.historywith the bottoken and returns
ts,thread_ts,user,bot_id,textand eachattachment's
title/text/fallback/fields, nothing else. Everyreturned
tsis remembered as matched for(connection, channel), inmemory, 24h TTL, bounded in size.
reply_broadcast), 32 KiB cap; 403parent-not-matchedunlessparent_tswas returned by a history readfor the same connection and channel; the only write is one
chat.postMessagewiththread_ts. The samerequest_idis 200{"duplicate":true}without posting; a different one is 409already-replied.hooks/server.go: the two routes on the subscriber mux, beside the other/v1/slackroutes.hooks/slack_test.go: tests for the disabled flag, the unallowed channel,the unmatched parent (including a match by another connection and one for
another channel), the duplicate/conflict reply, and the single
chat.postMessagepayload; the existing suite passes.hooks-service/docs/hooks.md: both endpoints, auth, allow-list, limitsand an error table.
hooks-service/README.md: the new flag in the flags table. Thebot-scope list already names
channels:historyandgroups:history.Testing
cd hooks-service && gofmt -l . && go vet ./... && go test -race ./...: pass(hooks package 22.5s, sentryx 0.02s).
Slack API:
TestSlackAlertChannelDisabled,TestSlackAlertChannelHistory,TestSlackAlertChannelReply.conversations.historycall, and the by-hand botscopes
channels:history/groups:historyare not yet confirmed installedon the team app (owner step, raised when this PR opens).
Out of scope
The BB-419 consumer, the stewards triage logic, any write other than the one
thread reply, persistence of match or reply state, and any change to the
session reply path.