fix: parent state cursor fallback#789
fix: parent state cursor fallback#789Maxime Carbonneau-Leclerc (maxi297) merged 1 commit intomainfrom
Conversation
👋 Greetings, Airbyte Team Member!Here are some helpful tips and reminders for your convenience. Testing 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@maxi297/fix_fallback_for_parent_state#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 maxi297/fix_fallback_for_parent_stateHelpful ResourcesPR Slash CommandsAirbyte Maintainers can execute the following slash commands on your PR:
|
📝 WalkthroughWalkthroughNarrowed condition in _instantiate_parent_stream_state_manager to construct a parent state only when the child state has exactly one cursor value. Added an explanatory comment about the expected child state shape. This changes the control flow by restricting when a parent state is derived from the child. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant Caller
participant ModelToComponentFactory as ModelToComponentFactory
participant ChildState as Child Stream State
participant ParentStateMgr as Parent State Manager
Caller->>ModelToComponentFactory: _instantiate_parent_stream_state_manager(child_state)
ModelToComponentFactory->>ChildState: Read cursor_values
alt Exactly one cursor value
Note over ModelToComponentFactory: len(cursor_values) == 1
ModelToComponentFactory->>ParentStateMgr: Construct from single cursor value
ModelToComponentFactory-->>Caller: Return ParentStateMgr
else Zero or multiple cursor values
Note over ModelToComponentFactory: Do not construct from child state
ModelToComponentFactory-->>Caller: Return None / alternate path
end
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Suggested reviewers
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
airbyte_cdk/sources/declarative/parsers/model_to_component_factory.py (1)
3868-3870: LGTM! The narrowed condition and explanatory comment improve safety.The change to only construct a parent state when
len(cursor_values) == 1is a sensible defensive improvement. By restricting the fallback to cases where the child state matches the expected simple structure ({<cursor_field>: <cursor_value>}), you avoid attempting to migrate states with unexpected shapes. The added comment clearly documents this assumption.One optional enhancement: When
len(cursor_values) != 1, the code silently returns an emptyConnectorStateManager. Would it be helpful to log a debug message in cases wherecursor_valuesexists but has more than one value? This could aid troubleshooting if users encounter unexpected state migration behavior, wdyt?
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
airbyte_cdk/sources/declarative/parsers/model_to_component_factory.py(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (12)
- GitHub Check: Check: source-hardcoded-records
- GitHub Check: Check: source-intercom
- GitHub Check: Check: source-pokeapi
- GitHub Check: Check: source-shopify
- GitHub Check: Check: destination-motherduck
- GitHub Check: Pytest (All, Python 3.13, Ubuntu)
- GitHub Check: Pytest (All, Python 3.10, Ubuntu)
- GitHub Check: Pytest (All, Python 3.12, Ubuntu)
- GitHub Check: Pytest (All, Python 3.11, Ubuntu)
- GitHub Check: SDM Docker Image Build
- GitHub Check: Manifest Server Docker Image Build
- GitHub Check: Pytest (Fast)
8158f0d
into
main
What
Addressing oncall issue https://github.com/airbytehq/oncall/issues/9163
How
Ensuring that the state migration only happens if the child state is
{<cursor_field>: <cursor value>}Summary by CodeRabbit