feat: add scopes object array to declarative OAuth spec#934
feat: add scopes object array to declarative OAuth spec#934Aldo Gonzalez (aldogonzalez8) merged 10 commits intomainfrom
Conversation
…declarative OAuth spec Adds structured scopes support to oauth_connector_input_specification: - scopes: array of strings, takes precedence over scope string - optional_scopes: array of optional scopes - scopes_join_strategy: enum (space/comma/plus), defaults to space per RFC 6749 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
👋 Greetings, Airbyte Team Member!Here are some helpful tips and reminders for your convenience. 💡 Show Tips and TricksTesting This CDK VersionYou can test this version of the CDK using the following: # Run the CLI from this branch:
uvx 'git+https://github.com/airbytehq/airbyte-python-cdk.git@aldo/scopes-array-schema#egg=airbyte-python-cdk[dev]' --help
# Update a connector to use the CDK from this branch ref:
cd airbyte-integrations/connectors/source-example
poe use-cdk-branch aldo/scopes-array-schemaPR Slash CommandsAirbyte Maintainers can execute the following slash commands on your PR:
|
|
Note Reviews pausedUse the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughAdds OAuth scope handling to the declarative connector schema and models: introduces a Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes 🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
airbyte_cdk/sources/declarative/declarative_component_schema.yaml (1)
3079-3088: Could we makeoptional_scopesmerge semantics explicit, wdyt?Would you clarify ordering/interaction with
scopes(and legacyscope) to avoid connector-side ambiguity?Proposed doc clarification
optional_scopes: title: Optional Scopes type: array items: type: string description: |- The DeclarativeOAuth Specific list of optional scopes to request from the OAuth provider. These scopes may or may not be granted depending on the provider and user consent. + If both `scopes` and `optional_scopes` are set, define whether `optional_scopes` are + appended before or after `scopes` prior to `scopes_join_strategy` application. + Also define behavior when only legacy `scope` is provided. examples: - ["admin:read"]🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@airbyte_cdk/sources/declarative/declarative_component_schema.yaml` around lines 3079 - 3088, Update the declarative_component_schema.yaml description for optional_scopes to explicitly state the merge semantics and interaction with scopes and legacy scope: clarify whether optional_scopes are appended to scopes (and to legacy scope if present), whether duplicates are removed or preserved, the order priority (e.g., scopes take precedence for required scopes and optional_scopes only requested if not present), and any normalization rules (case, whitespace, delimiter handling); reference the properties optional_scopes, scopes and scope in the text so connector authors know exactly how the final requested scope list is composed and ordered.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@airbyte_cdk/sources/declarative/declarative_component_schema.yaml`:
- Around line 3089-3099: The schema field scopes_join_strategy is unused at
runtime; update the factory that reads oauth_connector_input_specification to
parse scopes_join_strategy and pass it into the DeclarativeOauth2Authenticator
(or extend DeclarativeOauth2Authenticator to accept a scopes_join_strategy
parameter), then modify DeclarativeOauth2Authenticator's token-request
preparation logic to join the scopes array using the provided strategy (support
"space", "comma", "plus") before sending the OAuth request; alternatively, if
you prefer removal, delete scopes_join_strategy from the schema and any
references in oauth_connector_input_specification to avoid dead config.
---
Nitpick comments:
In `@airbyte_cdk/sources/declarative/declarative_component_schema.yaml`:
- Around line 3079-3088: Update the declarative_component_schema.yaml
description for optional_scopes to explicitly state the merge semantics and
interaction with scopes and legacy scope: clarify whether optional_scopes are
appended to scopes (and to legacy scope if present), whether duplicates are
removed or preserved, the order priority (e.g., scopes take precedence for
required scopes and optional_scopes only requested if not present), and any
normalization rules (case, whitespace, delimiter handling); reference the
properties optional_scopes, scopes and scope in the text so connector authors
know exactly how the final requested scope list is composed and ordered.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: ff8f9dfe-ff06-4069-b8b9-8386e64ac039
📒 Files selected for processing (2)
airbyte_cdk/sources/declarative/declarative_component_schema.yamlairbyte_cdk/sources/declarative/models/declarative_component_schema.py
Change scopes and optional_scopes from List[str] to List[OAuthScope] where each scope is an object with a required `scope` property. Uses additionalProperties: true for future extensibility. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: b0aca088-b25e-4c09-ace0-d055c2f5ed8b
📒 Files selected for processing (2)
airbyte_cdk/sources/declarative/declarative_component_schema.yamlairbyte_cdk/sources/declarative/models/declarative_component_schema.py
🚧 Files skipped from review as they are similar to previous changes (1)
- airbyte_cdk/sources/declarative/declarative_component_schema.yaml
…es fields Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
✅ Actions performedReviews paused. |
|
Aldo Gonzalez (@aldogonzalez8) the bunny will leave you alone now |
Thank you Christo Grabowski (@ChristoGrab) |
|
/prerelease |
…preserve scopes fields Override OauthConnectorInputSpecification and cascade through OAuthConfigSpecification -> AdvancedAuth -> ConnectorSpecification -> AirbyteMessage to ensure serpyco_rs preserves scopes, optional_scopes, and scopes_join_strategy fields during deserialization. Also convert ScopesJoinStrategy enum to string value in spec.py before passing to ConnectorSpecificationSerializer.load(). Fixes: airbytehq/airbyte-internal-issues#15963 Co-Authored-By: aldo.gonzalez@airbyte.io <aldo.gonzalez@airbyte.io>
Co-Authored-By: aldo.gonzalez@airbyte.io <aldo.gonzalez@airbyte.io>
Aldo Gonzalez (aldogonzalez8)
left a comment
There was a problem hiding this comment.
Review submitted
Validation of raised concerns against PR #934 + platform PR #18705I reviewed the full diff of this CDK PR and the companion platform PR (airbyte-platform-internal#18705) to validate the four concerns. All four reference symbols that do not exist in the actual codebase. Details below. Show/Hide Detailed Report1. "Unsafe
|
| # | Concern | Verdict |
|---|---|---|
| 1 | Unsafe ObjectNode cast in applyRequestedScopes |
Invalid — method doesn't exist; scope extraction uses safe JsonNode.path() |
| 2 | requestedOptionalScopes silently ignored |
Invalid — symbols don't exist; actual short-circuit is intentional |
| 3 | Format mismatch in StoredOAuthState |
Invalid — no typed scopes field; uses opaque JsonNode |
| 4 | Missing KDoc on requestedScopes in CloudOAuthServiceImpl |
Invalid — parameter doesn't exist |
All four concerns appear to reference an earlier draft or hallucinated code rather than the actual implementation. The PR's scope extraction logic uses safe Jackson APIs throughout, and the data flow preserves scope format correctly via JsonNode passthrough.
Updated validation — corrected concernsApologies for the earlier mismatch. Here's the validation against the actual 4 concerns, based on review of both the CDK diff and the companion platform PR (airbyte-platform-internal#18705). Show/Hide Detailed Report1. Fragile protocol override in
|
| # | Concern | Valid? | Severity | Suggestion |
|---|---|---|---|---|
| 1 | Fragile protocol override | Yes | Medium | Add sync-check test asserting upstream field subset |
| 2 | Type mismatch str vs ScopesJoinStrategy |
Yes (handled) | Low | Add clarifying comment on protocol field |
| 3 | .value on already-string |
Yes | High | Defensive hasattr(strategy, "value") guard |
| 4 | Duplicate "Scopes" title | Yes | Medium | Differentiate titles for UI clarity |
… scopes_join_strategy Co-Authored-By: aldo.gonzalez@airbyte.io <aldo.gonzalez@airbyte.io>
|
/prerelease
|
Summary
Add structured OAuth scope fields to
oauth_connector_input_specificationin the declarative component schema, replacing the freeformscopestring with an extensible object array.New fields
scopesarray[{scope: string}]scopestring.optional_scopesarray[{scope: string}]scopes_join_strategyenum(space, comma, plus)space(per RFC 6749).Schema design
Each scope is an object (
{ scope: "read" }) rather than a plain string. The object shape usesadditionalProperties: trueso future fields (e.g.,mode,entities) can be added without a schema change.Example
What this PR changes
declarative_component_schema.yaml— Addsscopes,optional_scopes,scopes_join_strategyunderOAuthConfigSpecification.oauth_connector_input_specificationdeclarative_component_schema.py— AddsOAuthScopemodel,ScopesJoinStrategyenum, and new fields onOauthConnectorInputSpecificationHow it works
These fields are not consumed by the CDK runtime. They define the manifest contract that the platform reads during the OAuth consent flow. The platform handler (
DeclarativeOAuthSpecHandler.kt) extracts scope values from the objects, joins them using the strategy, and populates URL template variables. See airbyte-platform-internal#18705.Related PRs
Test plan
scopestring continue to work unchanged🤖 Generated with Claude Code