Skip to content

feat: add condition to component mapping definition#667

Merged
pnilan merged 2 commits intomainfrom
pnilan/feat/add-optional-condition-to-component-mapping-definition
Jul 22, 2025
Merged

feat: add condition to component mapping definition#667
pnilan merged 2 commits intomainfrom
pnilan/feat/add-optional-condition-to-component-mapping-definition

Conversation

@pnilan
Copy link
Contributor

@pnilan pnilan commented Jul 22, 2025

What

  • Enables users to specify a condition to evaluate to determine if a ComponentMappingDefinition should resolve for ConfigComponentsResolver
  • Raises error on property usage for HttpComponentsResolver and ParameterizedComponentsResolver as these should always be mapped.
  • E.g. set an incremental_sync component conditionally if a user provided a cursor_field in their the dynamic stream config.

Review Order

  1. declarative_component_schema.py
  2. model_to_component_factory.py
  3. components_resolver.py
  4. config_components_resolver.py
  5. tests

Summary by CodeRabbit

  • New Features

    • Added support for conditional application of component mappings, allowing mappings to be applied only when specified conditions are met. Conditions can reference configuration and context values.
  • Bug Fixes

    • None.
  • Tests

    • Introduced new tests to validate that component mappings are correctly applied or skipped based on their conditions.

Copilot AI review requested due to automatic review settings July 22, 2025 20:53
@github-actions github-actions bot added the enhancement New feature or request label Jul 22, 2025
@github-actions
Copy link

👋 Greetings, Airbyte Team Member!

Here are some helpful tips and reminders for your convenience.

Testing This CDK Version

You 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@pnilan/feat/add-optional-condition-to-component-mapping-definition#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 pnilan/feat/add-optional-condition-to-component-mapping-definition

Helpful Resources

PR Slash Commands

Airbyte Maintainers can execute the following slash commands on your PR:

  • /autofix - Fixes most formatting and linting issues
  • /poetry-lock - Updates poetry.lock file
  • /test - Runs connector tests with the updated CDK
  • /poe <command> - Runs any poe command in the CDK environment

📝 Edit this welcome message.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds conditional evaluation capability to component mapping definitions, allowing users to specify conditions that must be met for a component mapping to be applied. This enables dynamic component resolution based on runtime context such as user configuration or stream-specific values.

  • Adds a new optional condition field to ComponentMappingDefinition schema and model
  • Updates all component resolvers to evaluate conditions before applying mappings
  • Implements condition evaluation using InterpolatedBoolean with access to configuration and component values

Reviewed Changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
declarative_component_schema.yaml Adds condition field definition to the schema with interpolation context
declarative_component_schema.py Adds condition field to ComponentMappingDefinition model
model_to_component_factory.py Updates factory to pass condition parameter and fixes method signature formatting
components_resolver.py Adds condition field to both ComponentMappingDefinition and ResolvedComponentMappingDefinition classes
config_components_resolver.py Implements condition evaluation logic in resolver
parametrized_components_resolver.py Implements condition evaluation logic in resolver
http_components_resolver.py Implements condition evaluation logic in resolver
test_config_components_resolver.py Adds comprehensive test coverage for various condition scenarios

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jul 22, 2025

📝 Walkthrough

Walkthrough

This change introduces an optional condition property to component mapping definitions in the declarative component schema and associated models. The ConfigComponentsResolver now supports evaluating these conditions, applying component mappings only when their conditions are met. New tests verify conditional mapping behavior in various scenarios.

Changes

File(s) Change Summary
airbyte_cdk/sources/declarative/declarative_component_schema.yaml Added optional condition property to ComponentMappingDefinition schema with interpolation support and examples.
airbyte_cdk/sources/declarative/models/declarative_component_schema.py Added optional condition field to ComponentMappingDefinition model class.
airbyte_cdk/sources/declarative/parsers/model_to_component_factory.py Propagated condition from model to definition; enforced that condition is only allowed for ConfigComponentsResolver; updated signature formatting and parameter passing.
airbyte_cdk/sources/declarative/resolvers/components_resolver.py Added optional condition field to ComponentMappingDefinition and ResolvedComponentMappingDefinition dataclasses.
airbyte_cdk/sources/declarative/resolvers/config_components_resolver.py Implemented conditional evaluation for component mappings; only applies mappings when their condition evaluates to true.
unit_tests/sources/declarative/resolvers/test_config_components_resolver.py Added parameterized tests and manifests to verify conditional component mapping logic.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant ConfigComponentsResolver
    participant ComponentMappingDefinition
    participant InterpolatedBoolean

    User->>ConfigComponentsResolver: resolve_components(stream_template_config)
    loop For each ComponentMappingDefinition
        ConfigComponentsResolver->>ComponentMappingDefinition: Access condition
        alt condition is set
            ConfigComponentsResolver->>InterpolatedBoolean: Evaluate condition with contexts
            InterpolatedBoolean-->>ConfigComponentsResolver: Return True/False
            alt condition is True
                ConfigComponentsResolver->>ConfigComponentsResolver: Apply mapping to config
            else condition is False
                ConfigComponentsResolver->>ConfigComponentsResolver: Skip mapping
            end
        else condition is not set
            ConfigComponentsResolver->>ConfigComponentsResolver: Apply mapping to config
        end
    end
    ConfigComponentsResolver-->>User: Return resolved components
Loading

Estimated code review effort

3 (~45 minutes)

Suggested reviewers

  • lazebnyi
  • aldogonzalez8

Would you like to suggest adding more test cases for edge conditions, such as invalid interpolation contexts or malformed expressions, wdyt?


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b0842e5 and af83b18.

📒 Files selected for processing (3)
  • airbyte_cdk/sources/declarative/declarative_component_schema.yaml (1 hunks)
  • airbyte_cdk/sources/declarative/models/declarative_component_schema.py (2 hunks)
  • airbyte_cdk/sources/declarative/parsers/model_to_component_factory.py (5 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
  • airbyte_cdk/sources/declarative/declarative_component_schema.yaml
  • airbyte_cdk/sources/declarative/models/declarative_component_schema.py
  • airbyte_cdk/sources/declarative/parsers/model_to_component_factory.py
⏰ 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). (10)
  • GitHub Check: Check: destination-motherduck
  • GitHub Check: Check: source-intercom
  • GitHub Check: Check: source-pokeapi
  • GitHub Check: Check: source-shopify
  • GitHub Check: Check: source-hardcoded-records
  • GitHub Check: Pytest (All, Python 3.10, Ubuntu)
  • GitHub Check: Pytest (Fast)
  • GitHub Check: Pytest (All, Python 3.11, Ubuntu)
  • GitHub Check: SDM Docker Image Build
  • GitHub Check: Analyze (python)
✨ Finishing Touches
  • 📝 Generate Docstrings

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.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

‼️ IMPORTANT
Auto-reply has been disabled for this repository in the CodeRabbit settings. The CodeRabbit bot will not respond to your replies unless it is explicitly tagged.

  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
airbyte_cdk/sources/declarative/declarative_component_schema.yaml (1)

4175-4184: Align condition defaults with existing schema conventions?

Many other condition properties in this schema (e.g. AddFields, RemoveFields, RecordFilter) specify an explicit default: "". Adding the same here would keep the contract symmetrical and avoid downstream validators treating the field as required when empty-string semantics are intended.

       description: A condition that must be met for the mapping to be applied.
       type: string
+      default: ""

Would you like to add this default for consistency, wdyt?

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 410571c and b0842e5.

📒 Files selected for processing (8)
  • airbyte_cdk/sources/declarative/declarative_component_schema.yaml (1 hunks)
  • airbyte_cdk/sources/declarative/models/declarative_component_schema.py (2 hunks)
  • airbyte_cdk/sources/declarative/parsers/model_to_component_factory.py (3 hunks)
  • airbyte_cdk/sources/declarative/resolvers/components_resolver.py (3 hunks)
  • airbyte_cdk/sources/declarative/resolvers/config_components_resolver.py (4 hunks)
  • airbyte_cdk/sources/declarative/resolvers/http_components_resolver.py (4 hunks)
  • airbyte_cdk/sources/declarative/resolvers/parametrized_components_resolver.py (4 hunks)
  • unit_tests/sources/declarative/resolvers/test_config_components_resolver.py (3 hunks)
🧠 Learnings (8)
📓 Common learnings
Learnt from: ChristoGrab
PR: airbytehq/airbyte-python-cdk#58
File: airbyte_cdk/sources/declarative/yaml_declarative_source.py:0-0
Timestamp: 2024-11-18T23:40:06.391Z
Learning: When modifying the `YamlDeclarativeSource` class in `airbyte_cdk/sources/declarative/yaml_declarative_source.py`, avoid introducing breaking changes like altering method signatures within the scope of unrelated PRs. Such changes should be addressed separately to minimize impact on existing implementations.
Learnt from: pnilan
PR: airbytehq/airbyte-python-cdk#0
File: :0-0
Timestamp: 2024-12-11T16:34:46.319Z
Learning: In the airbytehq/airbyte-python-cdk repository, the `declarative_component_schema.py` file is auto-generated from `declarative_component_schema.yaml` and should be ignored in the recommended reviewing order.
airbyte_cdk/sources/declarative/resolvers/components_resolver.py (2)

Learnt from: aaronsteers
PR: #174
File: airbyte_cdk/sources/declarative/parsers/model_to_component_factory.py:1093-1102
Timestamp: 2025-01-14T00:20:32.310Z
Learning: In the airbyte_cdk/sources/declarative/parsers/model_to_component_factory.py file, the strict module name checks in _get_class_from_fully_qualified_class_name (requiring module_name to be "components" and module_name_full to be "source_declarative_manifest.components") are intentionally designed to provide early, clear feedback when class declarations won't be found later in execution. These restrictions may be loosened in the future if the requirements for class definition locations change.

Learnt from: aaronsteers
PR: #58
File: airbyte_cdk/cli/source_declarative_manifest/_run.py:62-65
Timestamp: 2024-11-15T01:04:21.272Z
Learning: The files in airbyte_cdk/cli/source_declarative_manifest/, including _run.py, are imported from another repository, and changes to these files should be minimized or avoided when possible to maintain consistency.

airbyte_cdk/sources/declarative/models/declarative_component_schema.py (4)

Learnt from: pnilan
PR: airbytehq/airbyte-python-cdk#0
File: :0-0
Timestamp: 2024-12-11T16:34:46.319Z
Learning: In the airbytehq/airbyte-python-cdk repository, the declarative_component_schema.py file is auto-generated from declarative_component_schema.yaml and should be ignored in the recommended reviewing order.

Learnt from: aaronsteers
PR: #174
File: airbyte_cdk/sources/declarative/parsers/model_to_component_factory.py:1093-1102
Timestamp: 2025-01-14T00:20:32.310Z
Learning: In the airbyte_cdk/sources/declarative/parsers/model_to_component_factory.py file, the strict module name checks in _get_class_from_fully_qualified_class_name (requiring module_name to be "components" and module_name_full to be "source_declarative_manifest.components") are intentionally designed to provide early, clear feedback when class declarations won't be found later in execution. These restrictions may be loosened in the future if the requirements for class definition locations change.

Learnt from: ChristoGrab
PR: #58
File: airbyte_cdk/sources/declarative/yaml_declarative_source.py:0-0
Timestamp: 2024-11-18T23:40:06.391Z
Learning: When modifying the YamlDeclarativeSource class in airbyte_cdk/sources/declarative/yaml_declarative_source.py, avoid introducing breaking changes like altering method signatures within the scope of unrelated PRs. Such changes should be addressed separately to minimize impact on existing implementations.

Learnt from: aaronsteers
PR: #58
File: airbyte_cdk/cli/source_declarative_manifest/_run.py:62-65
Timestamp: 2024-11-15T01:04:21.272Z
Learning: The files in airbyte_cdk/cli/source_declarative_manifest/, including _run.py, are imported from another repository, and changes to these files should be minimized or avoided when possible to maintain consistency.

airbyte_cdk/sources/declarative/declarative_component_schema.yaml (2)

Learnt from: pnilan
PR: airbytehq/airbyte-python-cdk#0
File: :0-0
Timestamp: 2024-12-11T16:34:46.319Z
Learning: In the airbytehq/airbyte-python-cdk repository, the declarative_component_schema.py file is auto-generated from declarative_component_schema.yaml and should be ignored in the recommended reviewing order.

Learnt from: ChristoGrab
PR: #58
File: airbyte_cdk/sources/declarative/yaml_declarative_source.py:0-0
Timestamp: 2024-11-18T23:40:06.391Z
Learning: When modifying the YamlDeclarativeSource class in airbyte_cdk/sources/declarative/yaml_declarative_source.py, avoid introducing breaking changes like altering method signatures within the scope of unrelated PRs. Such changes should be addressed separately to minimize impact on existing implementations.

unit_tests/sources/declarative/resolvers/test_config_components_resolver.py (2)

Learnt from: aaronsteers
PR: #174
File: airbyte_cdk/sources/declarative/parsers/model_to_component_factory.py:1093-1102
Timestamp: 2025-01-14T00:20:32.310Z
Learning: In the airbyte_cdk/sources/declarative/parsers/model_to_component_factory.py file, the strict module name checks in _get_class_from_fully_qualified_class_name (requiring module_name to be "components" and module_name_full to be "source_declarative_manifest.components") are intentionally designed to provide early, clear feedback when class declarations won't be found later in execution. These restrictions may be loosened in the future if the requirements for class definition locations change.

Learnt from: aaronsteers
PR: #174
File: unit_tests/source_declarative_manifest/resources/source_the_guardian_api/components.py:21-29
Timestamp: 2025-01-13T23:39:15.457Z
Learning: The CustomPageIncrement class in unit_tests/source_declarative_manifest/resources/source_the_guardian_api/components.py is imported from another connector definition and should not be modified in this context.

airbyte_cdk/sources/declarative/resolvers/parametrized_components_resolver.py (3)

Learnt from: aaronsteers
PR: #174
File: airbyte_cdk/sources/declarative/parsers/model_to_component_factory.py:1093-1102
Timestamp: 2025-01-14T00:20:32.310Z
Learning: In the airbyte_cdk/sources/declarative/parsers/model_to_component_factory.py file, the strict module name checks in _get_class_from_fully_qualified_class_name (requiring module_name to be "components" and module_name_full to be "source_declarative_manifest.components") are intentionally designed to provide early, clear feedback when class declarations won't be found later in execution. These restrictions may be loosened in the future if the requirements for class definition locations change.

Learnt from: ChristoGrab
PR: #58
File: airbyte_cdk/sources/declarative/yaml_declarative_source.py:0-0
Timestamp: 2024-11-18T23:40:06.391Z
Learning: When modifying the YamlDeclarativeSource class in airbyte_cdk/sources/declarative/yaml_declarative_source.py, avoid introducing breaking changes like altering method signatures within the scope of unrelated PRs. Such changes should be addressed separately to minimize impact on existing implementations.

Learnt from: aaronsteers
PR: #58
File: airbyte_cdk/cli/source_declarative_manifest/_run.py:62-65
Timestamp: 2024-11-15T01:04:21.272Z
Learning: The files in airbyte_cdk/cli/source_declarative_manifest/, including _run.py, are imported from another repository, and changes to these files should be minimized or avoided when possible to maintain consistency.

airbyte_cdk/sources/declarative/resolvers/http_components_resolver.py (2)

Learnt from: aaronsteers
PR: #58
File: airbyte_cdk/cli/source_declarative_manifest/_run.py:62-65
Timestamp: 2024-11-15T01:04:21.272Z
Learning: The files in airbyte_cdk/cli/source_declarative_manifest/, including _run.py, are imported from another repository, and changes to these files should be minimized or avoided when possible to maintain consistency.

Learnt from: aaronsteers
PR: #174
File: airbyte_cdk/sources/declarative/parsers/model_to_component_factory.py:1093-1102
Timestamp: 2025-01-14T00:20:32.310Z
Learning: In the airbyte_cdk/sources/declarative/parsers/model_to_component_factory.py file, the strict module name checks in _get_class_from_fully_qualified_class_name (requiring module_name to be "components" and module_name_full to be "source_declarative_manifest.components") are intentionally designed to provide early, clear feedback when class declarations won't be found later in execution. These restrictions may be loosened in the future if the requirements for class definition locations change.

airbyte_cdk/sources/declarative/parsers/model_to_component_factory.py (4)

Learnt from: aaronsteers
PR: #174
File: airbyte_cdk/sources/declarative/parsers/model_to_component_factory.py:1093-1102
Timestamp: 2025-01-14T00:20:32.310Z
Learning: In the airbyte_cdk/sources/declarative/parsers/model_to_component_factory.py file, the strict module name checks in _get_class_from_fully_qualified_class_name (requiring module_name to be "components" and module_name_full to be "source_declarative_manifest.components") are intentionally designed to provide early, clear feedback when class declarations won't be found later in execution. These restrictions may be loosened in the future if the requirements for class definition locations change.

Learnt from: ChristoGrab
PR: #58
File: airbyte_cdk/sources/declarative/yaml_declarative_source.py:0-0
Timestamp: 2024-11-18T23:40:06.391Z
Learning: When modifying the YamlDeclarativeSource class in airbyte_cdk/sources/declarative/yaml_declarative_source.py, avoid introducing breaking changes like altering method signatures within the scope of unrelated PRs. Such changes should be addressed separately to minimize impact on existing implementations.

Learnt from: aaronsteers
PR: #58
File: airbyte_cdk/cli/source_declarative_manifest/_run.py:62-65
Timestamp: 2024-11-15T01:04:21.272Z
Learning: The files in airbyte_cdk/cli/source_declarative_manifest/, including _run.py, are imported from another repository, and changes to these files should be minimized or avoided when possible to maintain consistency.

Learnt from: pnilan
PR: airbytehq/airbyte-python-cdk#0
File: :0-0
Timestamp: 2024-12-11T16:34:46.319Z
Learning: In the airbytehq/airbyte-python-cdk repository, the declarative_component_schema.py file is auto-generated from declarative_component_schema.yaml and should be ignored in the recommended reviewing order.

🧬 Code Graph Analysis (4)
airbyte_cdk/sources/declarative/resolvers/components_resolver.py (1)
airbyte_cdk/sources/declarative/interpolation/interpolated_boolean.py (1)
  • InterpolatedBoolean (29-66)
airbyte_cdk/sources/declarative/resolvers/parametrized_components_resolver.py (1)
airbyte_cdk/sources/declarative/interpolation/interpolated_boolean.py (1)
  • InterpolatedBoolean (29-66)
airbyte_cdk/sources/declarative/resolvers/config_components_resolver.py (1)
airbyte_cdk/sources/declarative/interpolation/interpolated_boolean.py (1)
  • InterpolatedBoolean (29-66)
airbyte_cdk/sources/declarative/resolvers/http_components_resolver.py (1)
airbyte_cdk/sources/declarative/interpolation/interpolated_boolean.py (1)
  • InterpolatedBoolean (29-66)
🧰 Additional context used
🧠 Learnings (8)
📓 Common learnings
Learnt from: ChristoGrab
PR: airbytehq/airbyte-python-cdk#58
File: airbyte_cdk/sources/declarative/yaml_declarative_source.py:0-0
Timestamp: 2024-11-18T23:40:06.391Z
Learning: When modifying the `YamlDeclarativeSource` class in `airbyte_cdk/sources/declarative/yaml_declarative_source.py`, avoid introducing breaking changes like altering method signatures within the scope of unrelated PRs. Such changes should be addressed separately to minimize impact on existing implementations.
Learnt from: pnilan
PR: airbytehq/airbyte-python-cdk#0
File: :0-0
Timestamp: 2024-12-11T16:34:46.319Z
Learning: In the airbytehq/airbyte-python-cdk repository, the `declarative_component_schema.py` file is auto-generated from `declarative_component_schema.yaml` and should be ignored in the recommended reviewing order.
airbyte_cdk/sources/declarative/resolvers/components_resolver.py (2)

Learnt from: aaronsteers
PR: #174
File: airbyte_cdk/sources/declarative/parsers/model_to_component_factory.py:1093-1102
Timestamp: 2025-01-14T00:20:32.310Z
Learning: In the airbyte_cdk/sources/declarative/parsers/model_to_component_factory.py file, the strict module name checks in _get_class_from_fully_qualified_class_name (requiring module_name to be "components" and module_name_full to be "source_declarative_manifest.components") are intentionally designed to provide early, clear feedback when class declarations won't be found later in execution. These restrictions may be loosened in the future if the requirements for class definition locations change.

Learnt from: aaronsteers
PR: #58
File: airbyte_cdk/cli/source_declarative_manifest/_run.py:62-65
Timestamp: 2024-11-15T01:04:21.272Z
Learning: The files in airbyte_cdk/cli/source_declarative_manifest/, including _run.py, are imported from another repository, and changes to these files should be minimized or avoided when possible to maintain consistency.

airbyte_cdk/sources/declarative/models/declarative_component_schema.py (4)

Learnt from: pnilan
PR: airbytehq/airbyte-python-cdk#0
File: :0-0
Timestamp: 2024-12-11T16:34:46.319Z
Learning: In the airbytehq/airbyte-python-cdk repository, the declarative_component_schema.py file is auto-generated from declarative_component_schema.yaml and should be ignored in the recommended reviewing order.

Learnt from: aaronsteers
PR: #174
File: airbyte_cdk/sources/declarative/parsers/model_to_component_factory.py:1093-1102
Timestamp: 2025-01-14T00:20:32.310Z
Learning: In the airbyte_cdk/sources/declarative/parsers/model_to_component_factory.py file, the strict module name checks in _get_class_from_fully_qualified_class_name (requiring module_name to be "components" and module_name_full to be "source_declarative_manifest.components") are intentionally designed to provide early, clear feedback when class declarations won't be found later in execution. These restrictions may be loosened in the future if the requirements for class definition locations change.

Learnt from: ChristoGrab
PR: #58
File: airbyte_cdk/sources/declarative/yaml_declarative_source.py:0-0
Timestamp: 2024-11-18T23:40:06.391Z
Learning: When modifying the YamlDeclarativeSource class in airbyte_cdk/sources/declarative/yaml_declarative_source.py, avoid introducing breaking changes like altering method signatures within the scope of unrelated PRs. Such changes should be addressed separately to minimize impact on existing implementations.

Learnt from: aaronsteers
PR: #58
File: airbyte_cdk/cli/source_declarative_manifest/_run.py:62-65
Timestamp: 2024-11-15T01:04:21.272Z
Learning: The files in airbyte_cdk/cli/source_declarative_manifest/, including _run.py, are imported from another repository, and changes to these files should be minimized or avoided when possible to maintain consistency.

airbyte_cdk/sources/declarative/declarative_component_schema.yaml (2)

Learnt from: pnilan
PR: airbytehq/airbyte-python-cdk#0
File: :0-0
Timestamp: 2024-12-11T16:34:46.319Z
Learning: In the airbytehq/airbyte-python-cdk repository, the declarative_component_schema.py file is auto-generated from declarative_component_schema.yaml and should be ignored in the recommended reviewing order.

Learnt from: ChristoGrab
PR: #58
File: airbyte_cdk/sources/declarative/yaml_declarative_source.py:0-0
Timestamp: 2024-11-18T23:40:06.391Z
Learning: When modifying the YamlDeclarativeSource class in airbyte_cdk/sources/declarative/yaml_declarative_source.py, avoid introducing breaking changes like altering method signatures within the scope of unrelated PRs. Such changes should be addressed separately to minimize impact on existing implementations.

unit_tests/sources/declarative/resolvers/test_config_components_resolver.py (2)

Learnt from: aaronsteers
PR: #174
File: airbyte_cdk/sources/declarative/parsers/model_to_component_factory.py:1093-1102
Timestamp: 2025-01-14T00:20:32.310Z
Learning: In the airbyte_cdk/sources/declarative/parsers/model_to_component_factory.py file, the strict module name checks in _get_class_from_fully_qualified_class_name (requiring module_name to be "components" and module_name_full to be "source_declarative_manifest.components") are intentionally designed to provide early, clear feedback when class declarations won't be found later in execution. These restrictions may be loosened in the future if the requirements for class definition locations change.

Learnt from: aaronsteers
PR: #174
File: unit_tests/source_declarative_manifest/resources/source_the_guardian_api/components.py:21-29
Timestamp: 2025-01-13T23:39:15.457Z
Learning: The CustomPageIncrement class in unit_tests/source_declarative_manifest/resources/source_the_guardian_api/components.py is imported from another connector definition and should not be modified in this context.

airbyte_cdk/sources/declarative/resolvers/parametrized_components_resolver.py (3)

Learnt from: aaronsteers
PR: #174
File: airbyte_cdk/sources/declarative/parsers/model_to_component_factory.py:1093-1102
Timestamp: 2025-01-14T00:20:32.310Z
Learning: In the airbyte_cdk/sources/declarative/parsers/model_to_component_factory.py file, the strict module name checks in _get_class_from_fully_qualified_class_name (requiring module_name to be "components" and module_name_full to be "source_declarative_manifest.components") are intentionally designed to provide early, clear feedback when class declarations won't be found later in execution. These restrictions may be loosened in the future if the requirements for class definition locations change.

Learnt from: ChristoGrab
PR: #58
File: airbyte_cdk/sources/declarative/yaml_declarative_source.py:0-0
Timestamp: 2024-11-18T23:40:06.391Z
Learning: When modifying the YamlDeclarativeSource class in airbyte_cdk/sources/declarative/yaml_declarative_source.py, avoid introducing breaking changes like altering method signatures within the scope of unrelated PRs. Such changes should be addressed separately to minimize impact on existing implementations.

Learnt from: aaronsteers
PR: #58
File: airbyte_cdk/cli/source_declarative_manifest/_run.py:62-65
Timestamp: 2024-11-15T01:04:21.272Z
Learning: The files in airbyte_cdk/cli/source_declarative_manifest/, including _run.py, are imported from another repository, and changes to these files should be minimized or avoided when possible to maintain consistency.

airbyte_cdk/sources/declarative/resolvers/http_components_resolver.py (2)

Learnt from: aaronsteers
PR: #58
File: airbyte_cdk/cli/source_declarative_manifest/_run.py:62-65
Timestamp: 2024-11-15T01:04:21.272Z
Learning: The files in airbyte_cdk/cli/source_declarative_manifest/, including _run.py, are imported from another repository, and changes to these files should be minimized or avoided when possible to maintain consistency.

Learnt from: aaronsteers
PR: #174
File: airbyte_cdk/sources/declarative/parsers/model_to_component_factory.py:1093-1102
Timestamp: 2025-01-14T00:20:32.310Z
Learning: In the airbyte_cdk/sources/declarative/parsers/model_to_component_factory.py file, the strict module name checks in _get_class_from_fully_qualified_class_name (requiring module_name to be "components" and module_name_full to be "source_declarative_manifest.components") are intentionally designed to provide early, clear feedback when class declarations won't be found later in execution. These restrictions may be loosened in the future if the requirements for class definition locations change.

airbyte_cdk/sources/declarative/parsers/model_to_component_factory.py (4)

Learnt from: aaronsteers
PR: #174
File: airbyte_cdk/sources/declarative/parsers/model_to_component_factory.py:1093-1102
Timestamp: 2025-01-14T00:20:32.310Z
Learning: In the airbyte_cdk/sources/declarative/parsers/model_to_component_factory.py file, the strict module name checks in _get_class_from_fully_qualified_class_name (requiring module_name to be "components" and module_name_full to be "source_declarative_manifest.components") are intentionally designed to provide early, clear feedback when class declarations won't be found later in execution. These restrictions may be loosened in the future if the requirements for class definition locations change.

Learnt from: ChristoGrab
PR: #58
File: airbyte_cdk/sources/declarative/yaml_declarative_source.py:0-0
Timestamp: 2024-11-18T23:40:06.391Z
Learning: When modifying the YamlDeclarativeSource class in airbyte_cdk/sources/declarative/yaml_declarative_source.py, avoid introducing breaking changes like altering method signatures within the scope of unrelated PRs. Such changes should be addressed separately to minimize impact on existing implementations.

Learnt from: aaronsteers
PR: #58
File: airbyte_cdk/cli/source_declarative_manifest/_run.py:62-65
Timestamp: 2024-11-15T01:04:21.272Z
Learning: The files in airbyte_cdk/cli/source_declarative_manifest/, including _run.py, are imported from another repository, and changes to these files should be minimized or avoided when possible to maintain consistency.

Learnt from: pnilan
PR: airbytehq/airbyte-python-cdk#0
File: :0-0
Timestamp: 2024-12-11T16:34:46.319Z
Learning: In the airbytehq/airbyte-python-cdk repository, the declarative_component_schema.py file is auto-generated from declarative_component_schema.yaml and should be ignored in the recommended reviewing order.

🧬 Code Graph Analysis (4)
airbyte_cdk/sources/declarative/resolvers/components_resolver.py (1)
airbyte_cdk/sources/declarative/interpolation/interpolated_boolean.py (1)
  • InterpolatedBoolean (29-66)
airbyte_cdk/sources/declarative/resolvers/parametrized_components_resolver.py (1)
airbyte_cdk/sources/declarative/interpolation/interpolated_boolean.py (1)
  • InterpolatedBoolean (29-66)
airbyte_cdk/sources/declarative/resolvers/config_components_resolver.py (1)
airbyte_cdk/sources/declarative/interpolation/interpolated_boolean.py (1)
  • InterpolatedBoolean (29-66)
airbyte_cdk/sources/declarative/resolvers/http_components_resolver.py (1)
airbyte_cdk/sources/declarative/interpolation/interpolated_boolean.py (1)
  • InterpolatedBoolean (29-66)
⏰ 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). (8)
  • GitHub Check: Check: source-hardcoded-records
  • GitHub Check: Check: source-pokeapi
  • GitHub Check: Check: destination-motherduck
  • GitHub Check: Check: source-intercom
  • GitHub Check: Pytest (Fast)
  • GitHub Check: SDM Docker Image Build
  • GitHub Check: Pytest (All, Python 3.10, Ubuntu)
  • GitHub Check: Pytest (All, Python 3.11, Ubuntu)
🔇 Additional comments (21)
airbyte_cdk/sources/declarative/models/declarative_component_schema.py (1)

1497-1501: LGTM! The condition field addition looks great.

The new optional condition field is properly defined with correct typing, default value, and clear documentation. This supports the PR's goal of enabling conditional component mappings. Since this file is auto-generated from the YAML schema (as noted in the retrieved learnings), it looks like the generation process worked correctly, wdyt?

airbyte_cdk/sources/declarative/resolvers/components_resolver.py (1)

12-12: LGTM! Clean implementation of the conditional mapping feature.

The addition of the condition field to both dataclasses is well-structured. I like how you differentiate between the raw string condition in ComponentMappingDefinition and the evaluable InterpolatedBoolean in ResolvedComponentMappingDefinition - this follows a nice separation of concerns pattern, wdyt?

Also applies to: 26-26, 40-40

unit_tests/sources/declarative/resolvers/test_config_components_resolver.py (4)

176-176: Nice improvement to test clarity!

Adding explicit test IDs makes it much easier to identify specific test cases when they run or fail. This is a thoughtful enhancement to the existing test suite.


229-313: Comprehensive test coverage for conditional scenarios!

I really appreciate how thorough these test manifests are. You've covered all the key scenarios - always true/false conditions, component-value-dependent conditions, and mixed scenarios. The use of Jinja templating syntax like {{ components_values['name'] == 'item_1' }} nicely mirrors real-world usage patterns, wdyt?


316-376: Excellent parameterized test structure!

The test parameterization is very well organized. I particularly like how the expected_conditional_params clearly shows what parameters should be present for each stream based on the evaluated conditions. The test case mapping (e.g., item_1 gets conditional_param but item_2 doesn't) makes the expected behavior crystal clear, wdyt?


377-387: Clean and focused test implementation!

The test logic is straightforward and effective. Directly checking stream.retriever.requester._parameters is exactly the right place to verify that conditional mappings were applied correctly. The iteration through streams with the expected parameter validation provides good coverage, wdyt?

airbyte_cdk/sources/declarative/parsers/model_to_component_factory.py (3)

3803-3803: LGTM! Clean addition of condition support.

This change properly passes the condition attribute from the model to the ComponentMappingDefinition instance, enabling the conditional component mapping feature as intended in the PR.


3855-3857: Nice formatting improvement!

Breaking the method signature into explicit parameters on separate lines enhances readability. This makes the method signature more consistent with Python style guidelines, wdyt?


3877-3877: Good catch on parameter propagation!

Adding parameters=model.parameters ensures consistent parameter forwarding when creating components from mapping definitions. This maintains the parameter context throughout the component creation lifecycle, which is essential for proper interpolation and component behavior, wdyt?

airbyte_cdk/sources/declarative/resolvers/parametrized_components_resolver.py (4)

15-15: LGTM! Import addition looks good.

The InterpolatedBoolean import is correctly added and aligns with the conditional evaluation feature being introduced.


59-64: Nice conditional instantiation pattern!

The logic for creating InterpolatedBoolean instances only when a condition is present is clean and follows the expected null-safety pattern. This ensures we don't create unnecessary objects when no condition is specified. wdyt?


84-84: Condition properly passed to resolved component.

The condition is correctly propagated to the ResolvedComponentMappingDefinition instance, maintaining the data flow integrity.


101-106: Solid conditional evaluation logic!

The short-circuit logic is implemented correctly - if a condition exists and evaluates to false, the component is skipped. This provides the expected filtering behavior for conditional component mappings. The evaluation context includes both config and kwargs, which should provide access to all necessary interpolation variables. wdyt?

airbyte_cdk/sources/declarative/resolvers/config_components_resolver.py (4)

17-17: Import looks consistent across resolvers.

Good to see the InterpolatedBoolean import following the same pattern as the other resolvers in this PR.


74-79: Consistent conditional instantiation pattern.

This follows the exact same safe instantiation pattern as the parametrized resolver - creating InterpolatedBoolean only when needed. The architectural consistency across resolvers is excellent. wdyt about this uniform approach?


99-99: Condition propagation maintained.

The condition is properly passed to the resolved component definition, maintaining consistency with the other resolvers.


166-171: Conditional evaluation logic matches other resolvers.

The implementation is consistent with the parametrized resolver - proper null check and short-circuit behavior when conditions evaluate to false. The uniform implementation across all resolvers should make this feature predictable and maintainable. wdyt?

airbyte_cdk/sources/declarative/resolvers/http_components_resolver.py (4)

13-13: Import follows established pattern.

The InterpolatedBoolean import is consistent with the other resolvers in this feature implementation.


53-58: Same solid conditional instantiation approach.

The pattern matches the other resolvers perfectly - creating InterpolatedBoolean instances only when conditions are present. This consistency across all three resolver types should make the feature behavior predictable for users. wdyt?


77-77: Consistent condition propagation.

The condition is properly passed through to the resolved component definition, maintaining the established pattern.


108-113: Conditional evaluation with appropriate context.

The evaluation logic follows the same pattern as the other resolvers, with the addition of stream_slice in the kwargs which is appropriate for HTTP-based resolution. The conditional short-circuit behavior looks correct. Nice consistency across all resolver implementations! wdyt?

@github-actions
Copy link

github-actions bot commented Jul 22, 2025

PyTest Results (Fast)

3 700 tests  +5   3 689 ✅ +5   6m 37s ⏱️ +8s
    1 suites ±0      11 💤 ±0 
    1 files   ±0       0 ❌ ±0 

Results for commit af83b18. ± Comparison against base commit 410571c.

This pull request removes 4 and adds 9 tests. Note that renamed tests count towards both.
unit_tests.sources.declarative.resolvers.test_config_components_resolver ‑ test_dynamic_streams_read_with_config_components_resolver[manifest0-config0-None-expected_stream_names0]
unit_tests.sources.declarative.resolvers.test_config_components_resolver ‑ test_dynamic_streams_read_with_config_components_resolver[manifest1-config1-Dynamic streams list contains a duplicate name: item_2. Please check your configuration.-None]
unit_tests.sources.declarative.resolvers.test_config_components_resolver ‑ test_dynamic_streams_read_with_config_components_resolver[manifest2-config2-None-expected_stream_names2]
unit_tests.sources.declarative.resolvers.test_config_components_resolver ‑ test_dynamic_streams_read_with_config_components_resolver[manifest3-config3-None-expected_stream_names3]
unit_tests.sources.declarative.resolvers.test_config_components_resolver ‑ test_component_mapping_conditions[components_values_false_condition]
unit_tests.sources.declarative.resolvers.test_config_components_resolver ‑ test_component_mapping_conditions[components_values_true_condition]
unit_tests.sources.declarative.resolvers.test_config_components_resolver ‑ test_component_mapping_conditions[false_condition]
unit_tests.sources.declarative.resolvers.test_config_components_resolver ‑ test_component_mapping_conditions[mixed_conditions]
unit_tests.sources.declarative.resolvers.test_config_components_resolver ‑ test_component_mapping_conditions[true_condition]
unit_tests.sources.declarative.resolvers.test_config_components_resolver ‑ test_dynamic_streams_read_with_config_components_resolver[duplicates]
unit_tests.sources.declarative.resolvers.test_config_components_resolver ‑ test_dynamic_streams_read_with_config_components_resolver[no_duplicates]
unit_tests.sources.declarative.resolvers.test_config_components_resolver ‑ test_dynamic_streams_read_with_config_components_resolver[scanner_error]
unit_tests.sources.declarative.resolvers.test_config_components_resolver ‑ test_dynamic_streams_read_with_config_components_resolver[stream_configs_list]

♻️ This comment has been updated with latest results.

@github-actions
Copy link

github-actions bot commented Jul 22, 2025

PyTest Results (Full)

3 703 tests  +5   3 692 ✅ +5   18m 19s ⏱️ +18s
    1 suites ±0      11 💤 ±0 
    1 files   ±0       0 ❌ ±0 

Results for commit af83b18. ± Comparison against base commit 410571c.

This pull request removes 4 and adds 9 tests. Note that renamed tests count towards both.
unit_tests.sources.declarative.resolvers.test_config_components_resolver ‑ test_dynamic_streams_read_with_config_components_resolver[manifest0-config0-None-expected_stream_names0]
unit_tests.sources.declarative.resolvers.test_config_components_resolver ‑ test_dynamic_streams_read_with_config_components_resolver[manifest1-config1-Dynamic streams list contains a duplicate name: item_2. Please check your configuration.-None]
unit_tests.sources.declarative.resolvers.test_config_components_resolver ‑ test_dynamic_streams_read_with_config_components_resolver[manifest2-config2-None-expected_stream_names2]
unit_tests.sources.declarative.resolvers.test_config_components_resolver ‑ test_dynamic_streams_read_with_config_components_resolver[manifest3-config3-None-expected_stream_names3]
unit_tests.sources.declarative.resolvers.test_config_components_resolver ‑ test_component_mapping_conditions[components_values_false_condition]
unit_tests.sources.declarative.resolvers.test_config_components_resolver ‑ test_component_mapping_conditions[components_values_true_condition]
unit_tests.sources.declarative.resolvers.test_config_components_resolver ‑ test_component_mapping_conditions[false_condition]
unit_tests.sources.declarative.resolvers.test_config_components_resolver ‑ test_component_mapping_conditions[mixed_conditions]
unit_tests.sources.declarative.resolvers.test_config_components_resolver ‑ test_component_mapping_conditions[true_condition]
unit_tests.sources.declarative.resolvers.test_config_components_resolver ‑ test_dynamic_streams_read_with_config_components_resolver[duplicates]
unit_tests.sources.declarative.resolvers.test_config_components_resolver ‑ test_dynamic_streams_read_with_config_components_resolver[no_duplicates]
unit_tests.sources.declarative.resolvers.test_config_components_resolver ‑ test_dynamic_streams_read_with_config_components_resolver[scanner_error]
unit_tests.sources.declarative.resolvers.test_config_components_resolver ‑ test_dynamic_streams_read_with_config_components_resolver[stream_configs_list]

♻️ This comment has been updated with latest results.

@pnilan pnilan merged commit 51cfea5 into main Jul 22, 2025
27 of 28 checks passed
@pnilan pnilan deleted the pnilan/feat/add-optional-condition-to-component-mapping-definition branch July 22, 2025 22:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant