Skip to content

Conversation

@devin-ai-integration
Copy link
Contributor

@devin-ai-integration devin-ai-integration bot commented Dec 4, 2025

Description

Fixes a regression in Python SDKs where SyncClientWrapper and AsyncClientWrapper required a token parameter when is_auth_mandatory=True. This broke OAuth flows because the OAuthTokenProvider needs to create a wrapper without a token to fetch the initial token (only clientId and clientSecret are available at that point).

Link to Devin run: https://app.devin.ai/sessions/6d9d04443ed841218846f1fc37826bad
Requested by: [email protected] (@fern-support)

Updates Since Last Revision

Implemented a targeted fix that matches TypeScript's behavior:

  • OAuth flows: token is optional (OAuthTokenProvider needs to create wrapper before token exists)
  • Plain bearer auth: token is required when isAuthMandatory=true (preserves original behavior)

This replaces the previous approach that made token always optional for all bearer auth.

Changes Made

  • Added _has_oauth() method to detect OAuth authentication schemes
  • Modified client_wrapper_generator.py to use is_token_optional = self._has_oauth() or not self._context.ir.sdk_config.is_auth_mandatory
  • Token parameter and getter return type are now conditionally optional based on this logic
  • Updated versions.yml with version 4.42.1 changelog entry
  • Updated README.md generator (if applicable)

Testing

  • Ran pnpm seed:local test --generator python-sdk --fixture oauth-client-credentials - passed
  • Ran pnpm seed:local test --generator python-sdk --fixture bearer-token-environment-variable - passed
  • Ran poetry run ruff check and poetry run pre-commit run --all-files - passed

Human Review Checklist

⚠️ Please verify the targeted behavior:

  • For OAuth APIs: token parameter should be Optional[...] in the client wrapper (allows OAuthTokenProvider to bootstrap)
  • For plain bearer auth with isAuthMandatory=true: token parameter should be required (see seed/python-sdk/bearer-token-environment-variable/src/seed/core/client_wrapper.py - api_key is now required, not optional)
  • The _has_oauth() method checks scheme_as_union.type == "oauth" - verify this correctly identifies OAuth schemes in the IR

@devin-ai-integration
Copy link
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

devin-ai-integration bot and others added 3 commits December 4, 2025 22:12
… auth

This is a targeted fix that matches TypeScript's behavior:
- OAuth flows: token is optional (OAuthTokenProvider needs to create wrapper before token exists)
- Plain bearer auth: token is required when isAuthMandatory=true

Added _has_oauth() method to detect OAuth authentication and use it to determine
if the token parameter should be optional.

Co-Authored-By: [email protected] <[email protected]>
@devin-ai-integration devin-ai-integration bot changed the title fix(python): make token parameter optional in client wrapper for OAuth flows fix(python): make token parameter optional only for OAuth flows Dec 5, 2025
Added fix as version 4.42.1 since 4.42.0 and 4.41.11 were already taken in main.

Co-Authored-By: [email protected] <[email protected]>
@tstanmay13 tstanmay13 merged commit a132587 into main Dec 8, 2025
127 checks passed
@tstanmay13 tstanmay13 deleted the devin/1764885556-fix-oauth-token-optional branch December 8, 2025 22:12
devin-ai-integration bot added a commit that referenced this pull request Dec 8, 2025
This fixture tests OAuth flows where all business endpoints require
authentication (isAuthMandatory = true). Unlike existing OAuth fixtures
that have endpoints with auth: false (making isAuthMandatory = false),
this fixture ensures the token parameter remains optional for OAuth flows
even when auth is mandatory.

This would have caught the regression fixed in PR #11040 where OAuth-based
SDKs broke when all endpoints required authentication.

Co-Authored-By: [email protected] <[email protected]>
fern-support pushed a commit that referenced this pull request Dec 9, 2025
)

* test: add oauth-client-credentials-mandatory-auth fixture

This fixture tests OAuth flows where all business endpoints require
authentication (isAuthMandatory = true). Unlike existing OAuth fixtures
that have endpoints with auth: false (making isAuthMandatory = false),
this fixture ensures the token parameter remains optional for OAuth flows
even when auth is mandatory.

This would have caught the regression fixed in PR #11040 where OAuth-based
SDKs broke when all endpoints required authentication.

Co-Authored-By: [email protected] <[email protected]>

* chore(seed): add Swift snapshot for oauth-client-credentials-mandatory-auth fixture

Co-Authored-By: [email protected] <[email protected]>

* chore(seed): add ir-to-jsonschema snapshot for oauth-client-credentials-mandatory-auth fixture

Co-Authored-By: [email protected] <[email protected]>

* chore(seed): add oauth-client-credentials-mandatory-auth to ruby-sdk allowedFailures

Co-Authored-By: [email protected] <[email protected]>

* chore(seed): add oauth-client-credentials-mandatory-auth to csharp-sdk and java-sdk allowedFailures

Co-Authored-By: [email protected] <[email protected]>

* chore(seed): fix java-sdk allowedFailures entry to include :no-custom-config suffix

Co-Authored-By: [email protected] <[email protected]>

* chore(seed): fix python-sdk seed.yml merge conflict artifacts

Co-Authored-By: [email protected] <[email protected]>

---------

Co-authored-by: Devin AI <158243242+devin-ai-integration[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

Development

Successfully merging this pull request may close these issues.

2 participants