Repository navigation
feat: infer OAuth type from account definition when destination supports accounts - #6718
Conversation
| // If the destination has an account with an account definition for the given flow, | ||
| // the account definition's AuthenticationType is used to determine if it is OAuth. | ||
| // Otherwise, it falls back to checking the destination definition config. | ||
| func (d *DestinationT) IsOAuthDestination(flow common.RudderFlow) (bool, error) { |
There was a problem hiding this comment.
What about DestinationT#GetAccountID? Shouldn't we get the id from the account whenever there is one? Isn't our target state to eventually rely exclusively on accounts for all destinations?
Do we need a helper method?
// resolveAccount resolves the account associated with the destination based on the flow.
// It returns the account for the specified flow (delivery or delete) if it exists, otherwise it returns nil.
func (d *DestinationT) resolveAccount(flow common.RudderFlow) *Account {There was a problem hiding this comment.
Added resolveAccount as a helper and used it in both IsOAuthDestination and GetAccountID. Since we now always get the ID from the account object, GetAccountID was simplified further — it just calls resolveAccount and returns account.ID directly, with no need to check IsOAuthDestination at all.
| if !ok { | ||
| return "", fmt.Errorf("rudderAccountId is not a string") | ||
| account := d.resolveAccount(flow) | ||
| if account == nil { |
There was a problem hiding this comment.
Don't we want to fallback to the old behaviour if there is no account? ALL oauth destinations are going to have an account object? If so, then why do we still need to keep the fallback in IsOAuthDestination?
There was a problem hiding this comment.
Don't we want to fallback to the old behaviour if there is no account?
No, event in the current implementation we are throwing an error if there is no account. Unlike IsOAuthDestination, this method is explicitly asking for an account id
ALL oauth destinations are going to have an account object?
Yes all oauth destinations are going to have an account object. But not all these accounts will have a definition
If so, then why do we still need to keep the fallback in
IsOAuthDestination?
IsOAuthDestination is supposed to handle non-oauth destinations as well which might not have accounts.
There was a problem hiding this comment.
So, in DestinationT#IsOAuthDestination if account == nil then it should return false?
bcbbf6e to
447faf5
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #6718 +/- ##
==========================================
- Coverage 80.05% 79.80% -0.26%
==========================================
Files 566 565 -1
Lines 63368 63374 +6
==========================================
- Hits 50729 50573 -156
- Misses 9643 9811 +168
+ Partials 2996 2990 -6 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
🤖 I have created a release *beep* *boop* --- ## [1.70.0-rc.1](v1.69.0...v1.70.0-rc.1) (2026-03-16) ### Features * add a scheduled release cut workflow to cut release branches ([#6739](#6739)) ([ab887ac](ab887ac)) * infer OAuth type from account definition when destination supports accounts ([#6718](#6718)) ([00d1755](00d1755)) ### Bug Fixes * false sanity check failure due to empty response ([#6762](#6762)) ([0384603](0384603)) * gateway request blocked in store jobs blocking all other requests ([#6760](#6760)) ([ca4d514](ca4d514)) * respect context cancellation in gateway rate limiter ([#6751](#6751)) ([589251a](589251a)) * update prerelease branch versioning format in scheduled release workflow ([#6745](#6745)) ([fede9e4](fede9e4)) ### Miscellaneous * add check for pseudo-version dependencies in rudderlabs modules ([#6737](#6737)) ([55ecd10](55ecd10)) * bump rudder-go-kit to 0.73.0 ([#6753](#6753)) ([1743f6b](1743f6b)) * remove gunicorn and add darwin compatibility ([#6742](#6742)) ([392d1f4](392d1f4)) * use latest retryablehttp client ([#6754](#6754)) ([629f036](629f036)) * user rudo docker image for partition migration integration tests ([#6757](#6757)) ([5022fbd](5022fbd)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). Co-authored-by: rudderstack-github-actions[bot] <236995729+rudderstack-github-actions[bot]@users.noreply.github.com>
🤖 I have created a release *beep* *boop* --- ## [1.70.0](v1.69.0...v1.70.0) (2026-03-16) ### Features * add a scheduled release cut workflow to cut release branches ([#6739](#6739)) ([ab887ac](ab887ac)) * infer OAuth type from account definition when destination supports accounts ([#6718](#6718)) ([00d1755](00d1755)) ### Bug Fixes * false sanity check failure due to empty response ([#6762](#6762)) ([0384603](0384603)) * gateway request blocked in store jobs blocking all other requests ([#6760](#6760)) ([ca4d514](ca4d514)) * respect context cancellation in gateway rate limiter ([#6751](#6751)) ([589251a](589251a)) * update prerelease branch versioning format in scheduled release workflow ([#6745](#6745)) ([fede9e4](fede9e4)) ### Miscellaneous * add check for pseudo-version dependencies in rudderlabs modules ([#6737](#6737)) ([55ecd10](55ecd10)) * bump rudder-go-kit to 0.73.0 ([#6753](#6753)) ([1743f6b](1743f6b)) * remove gunicorn and add darwin compatibility ([#6742](#6742)) ([392d1f4](392d1f4)) * use latest retryablehttp client ([#6754](#6754)) ([629f036](629f036)) * user rudo docker image for partition migration integration tests ([#6757](#6757)) ([5022fbd](5022fbd)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). Co-authored-by: rudderstack-github-actions[bot] <236995729+rudderstack-github-actions[bot]@users.noreply.github.com>
Summary
When a destination supports accounts (i.e., has a
DeliveryAccountorDeleteAccountpopulated for the given flow), the OAuth type should be determined from the account definition rather than the destination definition.Changes:
IsOAuthDestinationnow checksaccount.AccountDefinition.AuthenticationTypefirst when thedestination has an account for the given flow, short-circuiting the destination definition check
oAuthinto two explicit constants —oAuthDestinationDefinitionAuthType("OAuth")and
oAuthAccountDefinitionAuthType("oauth") — to make the schema difference explicitLinear Ticket
https://linear.app/rudderstack/issue/INT-5712/fix-oauth-detection-logic-in-rudder-server
Security