[CHA-2961] Webhook handling spec — regenerate SDK + dual-API#57
Open
mogita wants to merge 6 commits into
Open
Conversation
…e + namespace fix)
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.
Ticket
Related
Summary
Regenerates the webhook surface from the chat/
feature/cha-2961-webhook-handling-specbranch + adds dual-API instance methods on the top-levelGetStreamRuby::Client.Added (rendered from chat/ template):
Stream::Webhookmodule alias (preferred);StreamChat::Webhookretained for backward-compat for one minor-version cycleStreamChat::Webhook::UnknownEventclass for forward-compatgunzip_payload,decode_sqs_payload,decode_sns_payloadprimitivesparse_event(payload)— returns typed event orUnknownEventfor unrecognized discriminators (forward-compat counterpart to the existingparse_webhook_eventwhich throws)verify_and_parse_webhook(body, signature, secret)HTTP compositeparse_sqs_payload(message_body)/parse_sns_payload(notification_body)queue composites — no signature param (backend emits no HMAC for queue messages today)StreamChat::Webhook::InvalidWebhookErrorcovering signature mismatch, invalid JSON, missing/non-stringtype, gzip decompression failure, invalid base64 in queue body, malformed SNS envelope. Distinguish failure modes via the message substring orcausechain.Hand-added on
GetStreamRuby::Client:verify_signature(body, signature)— drops theapi_secretparameter, uses@configuration.api_secretverify_and_parse_webhook(body, signature)— drops theapi_secretparameterDual API: module-level methods remain available for callers needing an arbitrary secret.
Conformance fixtures under
test/fixtures/webhooks/(14 event-type buckets +_invalid/negative cases).Generator change:
generate.shnow invokeschat-manager openapi generate-webhook-fixturesto populatetest/fixtures/webhooks/.Test plan
make testpasses (rspec suite; 12/12 green)_invalid/)Stream::WebhookandStreamChat::Webhookboth resolveverify_signaturereturns true/false correctly with stored secretverify_and_parse_webhookraisesInvalidWebhookErroron bad signaturelib/getstream_ruby/client.rbNotes for review
event_class_for_typereferencesStreamChat::*Eventconstants but generated models live underGetStream::Generated::Models::*. This affects typed-event return for known discriminators in both the oldparse_webhook_eventand the newparse_event. Out of scope for this PR (template-level mapping fix needed in chat/ codegen). Signature verification,UnknownEventfallback, queue/HTTP composites, and error handling all work correctly.test/webhook_test.rbis generated as Minitest and depends onminitest/autorun, which is not in this project's Gemfile. The repo's test infra is rspec underspec/. The generated Minitest file documents the surface and is not currently runnable bymake test— pre-existing situation.