Skip to content

fix(low-code cdk): Add literal type for ConfigNormalizationRules components#649

Merged
Patrick Nilan (pnilan) merged 1 commit intomainfrom
brian/require_type_on_config_normalization_rules
Jul 15, 2025
Merged

fix(low-code cdk): Add literal type for ConfigNormalizationRules components#649
Patrick Nilan (pnilan) merged 1 commit intomainfrom
brian/require_type_on_config_normalization_rules

Conversation

@brianjlai
Copy link
Copy Markdown
Contributor

@brianjlai Brian Lai (brianjlai) commented Jul 9, 2025

While implementing config validations for a connector, I noticed that we weren't requiring a type on the ConfigNormalizationRules component. For consistency we should do so.

The one annoying part is that this would technically constitute a breaking change because type will now be required on all instances of the type and no existing connectors contain it. Rather than institute a trivial breaking change, I propose that we prepare PRs for the few uses we have of this component that add the type. Merge this as a minor version, then update the base images for those connectors.

This should be relatively low risk since it will fail quite loudly and the changes themselves are quite trivial

Summary by CodeRabbit

  • New Features
    • The configuration now requires a "type" field for config normalization rules, ensuring clearer identification and validation.
  • Tests
    • Updated test manifests to include the required "type" field for config normalization rules.

@github-actions github-actions bot added the bug Something isn't working label Jul 9, 2025
@github-actions
Copy link
Copy Markdown

github-actions bot commented Jul 9, 2025

👋 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@brian/require_type_on_config_normalization_rules#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 brian/require_type_on_config_normalization_rules

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.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Jul 9, 2025

📝 Walkthrough

Walkthrough

The changes enforce that the config_normalization_rules object in both the schema and model definitions must include a type field with the fixed value "ConfigNormalizationRules". Corresponding updates were made to test manifests to include this required field.

Changes

File(s) Change Summary
airbyte_cdk/sources/declarative/declarative_component_schema.yaml Made type a required property of config_normalization_rules with a fixed value "ConfigNormalizationRules".
airbyte_cdk/sources/declarative/models/declarative_component_schema.py Added type: Literal["ConfigNormalizationRules"] as a required field to the ConfigNormalizationRules class.
unit_tests/sources/declarative/test_manifest_declarative_source.py Inserted "type": "ConfigNormalizationRules" into config_normalization_rules in test manifests.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Manifest
    participant SchemaValidator
    participant ConfigNormalizationRulesModel

    User->>Manifest: Defines config_normalization_rules with type="ConfigNormalizationRules"
    Manifest->>SchemaValidator: Validate manifest against schema
    SchemaValidator->>Manifest: Check for required type field
    SchemaValidator->>ConfigNormalizationRulesModel: Parse config_normalization_rules with type
    ConfigNormalizationRulesModel-->>SchemaValidator: Accept only if type="ConfigNormalizationRules"
    SchemaValidator-->>User: Validation result
Loading
✨ 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
Copy Markdown
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

♻️ Duplicate comments (4)
unit_tests/sources/declarative/test_manifest_declarative_source.py (4)

2562-2563: Same rationale as the earlier comment – duplication could be reduced by centralising the literal section.


2633-2634: See earlier note about extracting the repeated config_normalization_rules stanza.


2709-2710: See earlier note about extracting the repeated config_normalization_rules stanza.


2774-2775: See earlier note about extracting the repeated config_normalization_rules stanza.

🧹 Nitpick comments (3)
airbyte_cdk/sources/declarative/models/declarative_component_schema.py (1)

2160-2164: Consider making type defaulted rather than required, to smooth the rollout — wdyt?

Adding

type: Literal["ConfigNormalizationRules"]

does enforce the presence of the field at validation time. If you instead declare it as

-type: Literal["ConfigNormalizationRules"]
+type: Optional[Literal["ConfigNormalizationRules"]] = "ConfigNormalizationRules"

Pydantic will still coerce the constant value and ensure it’s correct, but existing manifests that omit the field will keep working. That can be useful while the “add-type” follow-up PRs roll out.

Also, because this file is auto-generated from the YAML schema, any manual edits can be blown away by the next code-gen run. Can you double-check that the YAML source already contains the same change and that this file is purely regenerated?

unit_tests/sources/declarative/test_manifest_declarative_source.py (1)

2491-2492: Consider extracting the new literal block into a shared helper to keep tests DRY, wdyt?

"type": "ConfigNormalizationRules" now appears verbatim in several test manifests. Moving the full config_normalization_rules dict (with the invariant type key) into a small fixture or helper factory would remove duplication and keep future edits in one place.

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

3838-3844: Literal type requirement looks great, but should we add a short description for consistency?

Other components generally include a description on the discriminator field—for example, see #/:definitions/ApiKeyAuthenticator/properties/type.
Adding one here would keep docs parity and help connector authors understand why the field is mandated, wdyt?

           type:
+            description: Discriminator – must always be "ConfigNormalizationRules".
             type: string
             enum: [ConfigNormalizationRules]
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 88f8256 and 68852a4.

📒 Files selected for processing (3)
  • airbyte_cdk/sources/declarative/declarative_component_schema.yaml (1 hunks)
  • airbyte_cdk/sources/declarative/models/declarative_component_schema.py (1 hunks)
  • unit_tests/sources/declarative/test_manifest_declarative_source.py (5 hunks)
🧰 Additional context used
🧠 Learnings (4)
📓 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.
unit_tests/sources/declarative/test_manifest_declarative_source.py (3)
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: aaronsteers
PR: airbytehq/airbyte-python-cdk#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: airbytehq/airbyte-python-cdk#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.
airbyte_cdk/sources/declarative/models/declarative_component_schema.py (3)
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: airbytehq/airbyte-python-cdk#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: 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.
airbyte_cdk/sources/declarative/declarative_component_schema.yaml (2)

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: 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>

⏰ 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). (9)
  • GitHub Check: Check: source-pokeapi
  • GitHub Check: Check: destination-motherduck
  • GitHub Check: Check: source-hardcoded-records
  • GitHub Check: Check: source-intercom
  • GitHub Check: Check: source-shopify
  • GitHub Check: SDM Docker Image Build
  • GitHub Check: Pytest (Fast)
  • GitHub Check: Pytest (All, Python 3.10, Ubuntu)
  • GitHub Check: Pytest (All, Python 3.11, Ubuntu)
🔇 Additional comments (1)
airbyte_cdk/sources/declarative/declarative_component_schema.yaml (1)

3838-3840: Heads-up: this will break manifests missing the new field—have downstream PRs landed?

Just double-checking: manifests that currently omit config_normalization_rules.type will now fail validation.
You mentioned coordinating follow-up PRs; once those are merged, we’re good. Could you confirm all affected connectors have updates queued, or should we gate this behind a minor version bump first, wdyt?

@github-actions
Copy link
Copy Markdown

github-actions bot commented Jul 9, 2025

PyTest Results (Fast)

3 693 tests  ±0   3 682 ✅ ±0   6m 20s ⏱️ -5s
    1 suites ±0      11 💤 ±0 
    1 files   ±0       0 ❌ ±0 

Results for commit 68852a4. ± Comparison against base commit 88f8256.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Jul 9, 2025

PyTest Results (Full)

3 696 tests  ±0   3 685 ✅ ±0   18m 23s ⏱️ +25s
    1 suites ±0      11 💤 ±0 
    1 files   ±0       0 ❌ ±0 

Results for commit 68852a4. ± Comparison against base commit 88f8256.

Copy link
Copy Markdown
Contributor

@pnilan Patrick Nilan (pnilan) left a comment

Choose a reason for hiding this comment

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

Thanks!

@pnilan Patrick Nilan (pnilan) merged commit b711cd6 into main Jul 15, 2025
26 of 27 checks passed
@pnilan Patrick Nilan (pnilan) deleted the brian/require_type_on_config_normalization_rules branch July 15, 2025 18:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants