Add Oura webhook subscriptions#926
Open
darinkrauss wants to merge 1 commit intodarin/refactor-work-mixinsfrom
Open
Add Oura webhook subscriptions#926darinkrauss wants to merge 1 commit intodarin/refactor-work-mixinsfrom
darinkrauss wants to merge 1 commit intodarin/refactor-work-mixinsfrom
Conversation
Contributor
darinkrauss
commented
Mar 24, 2026
- Add Oura webhook subscriptions
- Add Oura partner endpoints
- Add webhook work to periodically check and renew subscriptions
- Add custom error parser for Oura response with status 422
- Add UpdateSubscription struct and function
- Add OuraClient to data service context
- Add bson tags throughout in case struct is captured in persisted error
- Use time.ParseInLocation with default location time.UTC
- Add various Oura data validations
- Fix bugs
- Add and update tests
- https://tidepool.atlassian.net/browse/BACK-4027
- https://tidepool.atlassian.net/browse/BACK-4028
- https://tidepool.atlassian.net/browse/BACK-4029
- Add Oura webhook subscriptions - Add Oura partner endpoints - Add webhook work to periodically check and renew subscriptions - Add custom error parser for Oura response with status 422 - Add UpdateSubscription struct and function - Add OuraClient to data service context - Add bson tags throughout in case struct is captured in persisted error - Use time.ParseInLocation with default location time.UTC - Add various Oura data validations - Fix bugs - Add and update tests - https://tidepool.atlassian.net/browse/BACK-4027 - https://tidepool.atlassian.net/browse/BACK-4028 - https://tidepool.atlassian.net/browse/BACK-4029
There was a problem hiding this comment.
Pull request overview
Adds end-to-end support for Oura webhook subscription management (partner verification endpoint + periodic subscription sync/renew work), along with related client changes, validation updates, and broader BSON serialization coverage.
Changes:
- Introduces Oura webhook subscription synchronization work (create/update/renew) and wires it into the work coordinator.
- Adds Oura partner webhook verification endpoint and threads an
OuraClientthrough the data service context/API. - Expands Oura models/validation (incl.
UpdateSubscription,Subscriptionsparsing/validation), adds BSON tags for persistence/serializable errors, and standardizes time parsing to UTC.
Reviewed changes
Copilot reviewed 42 out of 42 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| work/store/structured/mongo/mongo.go | Improves logging around work creation and duplicate-key handling. |
| test/array.go | Adds generic helper to convert typed slices to []any for serialization tests. |
| structure/validator/string.go | Parses times in UTC by default. |
| structure/parser/object_parser.go | Parses times in UTC by default. |
| structure/parser/array_parser.go | Parses times in UTC by default. |
| request/values_parser.go | Parses times in UTC by default. |
| request/parser.go | Parses time headers in UTC by default. |
| oura/work/processors/processors_test.go | Updates EnsureWork tests for new signature and webhook subscribe work creation. |
| oura/work/processors/processors.go | Changes EnsureWork to accept (ctx, workClient) and enqueue webhook subscribe work. |
| oura/webhook/work/subscribe/processor_test.go | Adds comprehensive tests for subscription create/update/renew behavior. |
| oura/webhook/work/subscribe/processor.go | Implements subscription synchronization logic (list/create/update/renew). |
| oura/webhook/webhook_test.go | Renames webhook path constant and adds BSON serialization assertions. |
| oura/webhook/webhook.go | Renames WebhookPathEvent → EventPath and adds BSON tags to webhook structs. |
| oura/test/oura_mocks.go | Updates mocks for expanded Oura client/base client interfaces and signature changes. |
| oura/test/oura.go | Adds UpdateSubscription test helpers and improves subscription serialization helpers. |
| oura/service/api/v1/v1.go | Wires Oura webhook routes using the renamed EventPath. |
| oura/service/api/v1/subscription.go | Implements webhook verification (challenge response + token validation). |
| oura/provider/provider.go | Switches to OAuth provider client with custom error parser; stores partner URL as string. |
| oura/provider/config.go | Adds BSON tags to partner config fields. |
| oura/oura_test.go | Adds/extends tests for new constants, subscription structs, validators, and BSON serialization. |
| oura/oura.go | Adds subscription structs/validation, subscriptions collection helpers, constants, and BSON tags. |
| oura/data/work/setup/processor_test.go | Adjusts expectations ordering around data source deletion/update. |
| oura/data/work/historic/processor_test.go | Adds BSON serialization assertions for work metadata. |
| oura/data/work/historic/processor.go | Adds BSON inline tags to metadata structs. |
| oura/data/work/event/processor_test.go | Adds BSON serialization assertions for work metadata. |
| oura/data/work/event/processor.go | Adds BSON inline tags to metadata structs. |
| oura/client/error_parser.go | Adds custom 422 → 400-style error parsing with response metadata capture. |
| oura/client/client.go | Implements subscription CRUD/renew calls; refactors request sending and metrics patterns. |
| data/work/mixin_test.go | Refactors tests to match new replace/delete/update sequencing. |
| data/work/mixin.go | Moves original data source deletion earlier to avoid providerSessionId uniqueness conflicts. |
| data/source/source_test.go | Adds BSON serialization assertions for filter/create/update structs. |
| data/source/source.go | Adds BSON tags across data source API structs. |
| data/service/service/standard.go | Ensures Oura work with logger context; threads Oura client into API creation. |
| data/service/context/standard.go | Adds OuraClient to standard data service context. |
| data/service/context.go | Extends data service context interface with OuraClient(). |
| data/service/api/v1/v1.go | Registers Oura service API v1 routes. |
| data/service/api/v1/users_datasets_create_test.go | Updates mock context to satisfy new OuraClient() requirement. |
| data/service/api/standard.go | Threads Oura client through API standard construction and request context creation. |
| data/raw/raw_test.go | Adds BSON serialization checks (one formatting issue found in review). |
| data/raw/raw.go | Adds BSON tags across raw data API structs. |
| auth/service/service/service.go | Moves reconciler ensure step after registering processor factories. |
| auth/provider_session.go | Adds BSON tags to provider session filter. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
toddkazakov
reviewed
Mar 25, 2026
Contributor
Author
|
Updates based upon feedback included in later PR. |
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.