Skip to content

fix: add array type to field_pointers items #658

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 16, 2025
Merged

Conversation

lmossman
Copy link
Contributor

@lmossman lmossman commented Jul 16, 2025

The items field of field_pointers in declarative_component_schema has a nested items field, since that is meant to contain nested array values.

However, there is no type: array on the outer items schema, which causes issues in the Builder UI as it relies on the types of fields to know what to render.

This PR fixes the issue by explicitly declaring type: array on the outer items field.

Summary by CodeRabbit

  • New Features

    • Expanded support for custom configuration transformations, allowing additional transformation types in configuration migration and normalization rules.
  • Bug Fixes

    • Improved schema validation for transformation definitions by clarifying the expected structure of field pointers.

@lmossman lmossman requested review from Copilot and ChristoGrab and removed request for Copilot July 16, 2025 19:11
@github-actions github-actions bot added bug Something isn't working security labels Jul 16, 2025
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@lmossman/add-array-type#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 lmossman/add-array-type

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 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 ensures the field_pointers.items schema is correctly declared as an array by adding type: array in the YAML, and regenerates the Python models to reflect that change.

  • Added type: array to the outer items in field_pointers in the YAML schema.
  • Regenerated the Python datamodel, which updated ordering and details of CustomConfigTransformation.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
airbyte_cdk/sources/declarative/declarative_component_schema.yaml Added type: array to outer items in field_pointers definition.
airbyte_cdk/sources/declarative/models/declarative_component_schema.py Regenerated model code; moved and updated CustomConfigTransformation.
Comments suppressed due to low confidence (2)

airbyte_cdk/sources/declarative/models/declarative_component_schema.py:1646

  • [nitpick] The title="Class Name" argument was removed from this Field, which may affect autogenerated docs or UI labels. Consider re-adding the title to keep the schema documentation consistent.
    class_name: str = Field(

airbyte_cdk/sources/declarative/models/declarative_component_schema.py:1644

  • The inner Config class with extra = Extra.allow was removed in this regeneration, which changes Pydantic's validation behavior for extra fields. Re-add class Config: extra = Extra.allow to maintain existing model behavior.
class CustomConfigTransformation(BaseModel):

Copy link
Contributor

coderabbitai bot commented Jul 16, 2025

📝 Walkthrough

Walkthrough

This update clarifies the schema for the RemoveFields transformation by specifying that each field_pointers item is an array of strings. It also redefines the CustomConfigTransformation class, removes its inner Config subclass, and adds it to the allowed transformation types in ConfigMigration and ConfigNormalizationRules.

Changes

File(s) Change Summary
airbyte_cdk/sources/declarative/declarative_component_schema.yaml Explicitly declared type: array for items in the field_pointers property of the RemoveFields transformation.
airbyte_cdk/sources/declarative/models/declarative_component_schema.py Redefined CustomConfigTransformation, removed inner Config subclass, added to transformation unions in two classes.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant ConfigMigration
    participant ConfigNormalizationRules
    participant CustomConfigTransformation

    User->>ConfigMigration: Provide transformation config (may include CustomConfigTransformation)
    ConfigMigration->>CustomConfigTransformation: Invoke transformation logic
    User->>ConfigNormalizationRules: Provide normalization rules (may include CustomConfigTransformation)
    ConfigNormalizationRules->>CustomConfigTransformation: Invoke transformation logic
Loading

Would you like me to draft a more detailed diagram or breakdown of the new CustomConfigTransformation class structure, or is this overview sufficient for your review, 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 445c861 and 727b81c.

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

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/models/declarative_component_schema.py (1)

1-3: Note: This is auto-generated code - focus review on source YAML file.

Based on the file header and previous learnings, this file is auto-generated from declarative_component_schema.yaml. While the generated changes look correct, the real review should focus on the source YAML file to ensure the schema definitions are properly structured there. The changes here are just the Python representation of those schema updates, 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 b711cd6 and 445c861.

📒 Files selected for processing (2)
  • airbyte_cdk/sources/declarative/declarative_component_schema.yaml (1 hunks)
  • airbyte_cdk/sources/declarative/models/declarative_component_schema.py (3 hunks)
🧰 Additional context used
🧠 Learnings (2)
airbyte_cdk/sources/declarative/declarative_component_schema.yaml (3)

undefined

<retrieved_learning>
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.
</retrieved_learning>

<retrieved_learning>
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.
</retrieved_learning>

<retrieved_learning>
Learnt from: aaronsteers
PR: #58
File: airbyte_cdk/cli/source_declarative_manifest/spec.json:9-15
Timestamp: 2024-11-15T00:59:08.154Z
Learning: When code in airbyte_cdk/cli/source_declarative_manifest/ is being imported from another repository, avoid suggesting modifications to it during the import process.
</retrieved_learning>

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

undefined

<retrieved_learning>
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.
</retrieved_learning>

<retrieved_learning>
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.
</retrieved_learning>

<retrieved_learning>
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.
</retrieved_learning>

<retrieved_learning>
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.
</retrieved_learning>

<retrieved_learning>
Learnt from: ChristoGrab
PR: #221
File: airbyte_cdk/sources/utils/transform.py:0-0
Timestamp: 2025-01-16T00:50:39.069Z
Learning: In the TypeTransformer class, the data being transformed comes from API responses or source systems, so only standard JSON-serializable types are expected. The python_to_json mapping covers all expected types, and it's designed to fail fast (KeyError) on unexpected custom types rather than providing fallbacks.
</retrieved_learning>

🧬 Code Graph Analysis (1)
airbyte_cdk/sources/declarative/models/declarative_component_schema.py (2)
airbyte_cdk/sources/declarative/transformations/config_transformations/remap_field.py (1)
  • ConfigRemapField (16-65)
airbyte_cdk/sources/declarative/transformations/config_transformations/add_fields.py (1)
  • ConfigAddFields (22-106)
⏰ 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: source-shopify
  • GitHub Check: Check: source-hardcoded-records
  • GitHub Check: Check: source-intercom
  • GitHub Check: Check: destination-motherduck
  • GitHub Check: Check: source-pokeapi
  • GitHub Check: Pytest (All, Python 3.11, Ubuntu)
  • GitHub Check: Pytest (Fast)
  • GitHub Check: Pytest (All, Python 3.10, Ubuntu)
  • GitHub Check: SDM Docker Image Build
  • GitHub Check: Analyze (python)
🔇 Additional comments (4)
airbyte_cdk/sources/declarative/declarative_component_schema.yaml (1)

3397-3404: Inner type: array addition looks good – have you regenerated the auto-generated .py schema as well, wdyt?

The new type: array under field_pointers.items correctly tells the validator that each pointer is itself an array.
Because declarative_component_schema.py is generated from this YAML, please make sure you run the generation script so the Python artefact stays in sync and downstream builds don’t pick up mismatched schemas.

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

1644-1656: LGTM! The CustomConfigTransformation class follows established patterns.

The class definition is well-structured and consistent with other custom transformation classes in the file. The field descriptions are clear and the parameter structure aligns with the existing codebase patterns.


1165-1170: Good addition of CustomConfigTransformation to ConfigMigration transformations.

The union type expansion properly includes the new CustomConfigTransformation alongside the existing transformation types. The formatting is consistent and the change enables custom config transformations to be used in config migrations, which seems like a logical extension.


1190-1195: Consistent addition of CustomConfigTransformation to ConfigNormalizationRules.

The union type expansion mirrors the ConfigMigration changes and maintains consistency across the schema. This enables custom config transformations to be used in normalization rules as well.

However, I notice the PR objectives mention adding type: array to field_pointers items, but I don't see those specific changes in the visible code. Could you clarify if those changes are in the YAML source file that generates this code, or if they're related to the RemoveFields transformation mentioned in the AI summary? Just want to make sure we're addressing the core issue described in the PR objectives, wdyt?

Copy link

github-actions bot commented Jul 16, 2025

PyTest Results (Fast)

3 695 tests  ±0   3 684 ✅ ±0   6m 23s ⏱️ +5s
    1 suites ±0      11 💤 ±0 
    1 files   ±0       0 ❌ ±0 

Results for commit 727b81c. ± Comparison against base commit b711cd6.

♻️ This comment has been updated with latest results.

Copy link

github-actions bot commented Jul 16, 2025

PyTest Results (Full)

3 698 tests  ±0   3 687 ✅ ±0   17m 51s ⏱️ -19s
    1 suites ±0      11 💤 ±0 
    1 files   ±0       0 ❌ ±0 

Results for commit 727b81c. ± Comparison against base commit b711cd6.

♻️ This comment has been updated with latest results.

Copy link
Collaborator

@ChristoGrab ChristoGrab left a comment

Choose a reason for hiding this comment

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

LGTM! Thanks for cleaning up the CustomConfigTransformation class as well 👍

@lmossman lmossman merged commit c700900 into main Jul 16, 2025
26 checks passed
@lmossman lmossman deleted the lmossman/add-array-type branch July 16, 2025 21:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working security
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants