fix(hub): add /api/v1/broker/callback route - #1436
Closed
ptone wants to merge 2 commits into
Closed
Conversation
The Teams broker plugin's HubClient.DeliverCallback() sends callback
data (e.g. interactive card responses, action acknowledgements) to
POST /api/v1/broker/callback, but no handler existed on the hub server
— the delivery silently failed.
Add handleBrokerCallback with broker HMAC authentication (same auth
pattern as handleBrokerInbound), register the route, and add route
metadata. The callback payload (generic map[string]interface{} data) is
semantically different from inbound messages (structured Topic + Message),
so a dedicated handler is the correct approach.
Delete the mock-based TestHubClient_DeliverCallback test that asserted
against the non-existent route. Replace it with server-side handler tests
that exercise the real route through the hub mux, covering success,
auth failure, method not allowed, nil data, and invalid JSON cases.
Owner
Author
Code Review: APPROVE ✅Risk: LOW — Adds dedicated (Posted as comment because the token cannot self-approve.) Verified
Optional observation (non-blocking)The handler currently logs the callback and returns Clean change. Correct architectural decision to use a dedicated handler rather than overloading |
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.
Summary
handleBrokerCallbackhandler forPOST /api/v1/broker/callback— the endpoint the Teams broker plugin'sHubClient.DeliverCallback()calls to deliver interactive card responses and action acknowledgements.server.gowith broker HMAC auth (same pattern as/api/v1/broker/inbound), add route metadata and classification entries.TestHubClient_DeliverCallbacktest that asserted against the non-existent route, and replace it with 5 server-side handler tests exercising the real route through the hub mux.Design decision: Option A (new dedicated handler)
The callback payload (
Data map[string]interface{}) is structurally different from the inbound message format (Topic+*messages.StructuredMessage). Routing callback data throughhandleBrokerInboundwould fail validation, so a dedicated handler is the correct approach.Test plan
go build ./...passesgo vet ./...passesgo test ./extras/scion-teams/...passes (mock test removed)go test ./pkg/hub/ -run TestHandleBrokerCallback— 5 tests pass (success, no auth, method not allowed, nil data, invalid JSON)go test ./pkg/hub/ -run TestHandleBrokerInbound— existing inbound tests still passgo test ./pkg/hub/ -run TestRegisteredRoutesHavePermissionClassification— route metadata test passes