Skip to content

feat: infer OAuth type from account definition when destination supports accounts - #6718

Merged
shekhar-rudder merged 3 commits into
masterfrom
int-5712-destination-oauth-logic
Mar 3, 2026
Merged

shekhar-rudder merged 3 commits into
masterfrom
int-5712-destination-oauth-logic

Conversation

@shekhar-rudder

@shekhar-rudder shekhar-rudder commented Feb 24, 2026 •

Copy link
Copy Markdown
Member

Summary

When a destination supports accounts (i.e., has a DeliveryAccount or DeleteAccount populated for the given flow), the OAuth type should be determined from the account definition rather than the destination definition.

Changes:

  • IsOAuthDestination now checks account.AccountDefinition.AuthenticationType first when the
    destination has an account for the given flow, short-circuiting the destination definition check
  • Renamed oAuth into two explicit constants — oAuthDestinationDefinitionAuthType ("OAuth")
    and oAuthAccountDefinitionAuthType ("oauth") — to make the schema difference explicit

Linear Ticket

https://linear.app/rudderstack/issue/INT-5712/fix-oauth-detection-logic-in-rudder-server

Security

  • The code changed/added as part of this pull request won't create any security issues with how the software is being used.

Comment thread backend-config/oauth.go Resolved
Comment thread backend-config/oauth.go
// 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) {

@atzoum atzoum Feb 25, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 {

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread backend-config/oauth.go Resolved
Comment thread backend-config/oauth.go Resolved
Comment thread backend-config/oauth.go Resolved
Comment thread backend-config/oauth.go
if !ok {
return "", fmt.Errorf("rudderAccountId is not a string")
account := d.resolveAccount(flow)
if account == nil {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@atzoum atzoum Feb 26, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, in DestinationT#IsOAuthDestination if account == nil then it should return false?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right

@shekhar-rudder
shekhar-rudder force-pushed the int-5712-destination-oauth-logic branch from bcbbf6e to 447faf5 Compare February 25, 2026 13:48
@achettyiitr
achettyiitr requested a review from ItsSudip February 27, 2026 11:20
@codecov

codecov Bot commented Mar 3, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 92.85714% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 79.80%. Comparing base (e379c1f) to head (91760bb).
⚠️ Report is 10 commits behind head on master.

Files with missing lines Patch % Lines
backend-config/oauth.go 92.85% 1 Missing ⚠️
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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@shekhar-rudder
shekhar-rudder merged commit ec57028 into master Mar 3, 2026
101 of 103 checks passed
@shekhar-rudder
shekhar-rudder deleted the int-5712-destination-oauth-logic branch March 3, 2026 15:26
itsmihir pushed a commit that referenced this pull request Mar 16, 2026
🤖 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>
itsmihir pushed a commit that referenced this pull request Mar 17, 2026
🤖 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants