Skip to content

feat: enable custom validation strategies #610

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
Jun 25, 2025

Conversation

pnilan
Copy link
Contributor

@pnilan pnilan commented Jun 25, 2025

What

  • Enables custom validations strategies

Note

  • There are some unrelated component title/descriptions changes reflected in the declarative_component_schema.py from a previous PR: e44362a

Summary by CodeRabbit

  • New Features

    • Added support for custom validation strategies in declarative source configurations, allowing users to specify custom validation logic.
    • Introduced the ability to define multiple cursor datetime formats for stream cursors.
  • Improvements

    • Enhanced schema examples for better readability.
    • Reorganized and clarified configuration fields and descriptions for datetime-based cursors.
    • Standardized the order of selectable options in various configuration unions for consistency.

@pnilan pnilan requested a review from brianjlai June 25, 2025 17:26
@github-actions github-actions bot added the enhancement New feature or request label Jun 25, 2025
@pnilan pnilan marked this pull request as ready for review June 25, 2025 17:26
@Copilot Copilot AI review requested due to automatic review settings June 25, 2025 17:26
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 introduces support for custom validation strategies in the declarative component framework. Key changes include:

  • Importing and mapping the new CustomValidationStrategyModel in model_to_component_factory.py.
  • Adding a new CustomValidationStrategy Pydantic model in declarative_component_schema.py.
  • Updating YAML definitions and reordering some union type members in various component models.

Reviewed Changes

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

File Description
airbyte_cdk/sources/declarative/parsers/model_to_component_factory.py Added import and mapping support for the new CustomValidationStrategyModel.
airbyte_cdk/sources/declarative/models/declarative_component_schema.py Introduced the CustomValidationStrategy model and adjusted field types/unions in related models.
airbyte_cdk/sources/declarative/declarative_component_schema.yaml Updated schema examples and definitions to include CustomValidationStrategy.
Comments suppressed due to low confidence (1)

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

  • The 'class_name' field description mentions 'custom decoding' which may not align with the intended purpose of custom validation. Consider updating the description to reference 'custom validation logic' or a similar phrase to avoid confusion.
    )

Copy link
Contributor

coderabbitai bot commented Jun 25, 2025

📝 Walkthrough

Walkthrough

The updates introduce a new CustomValidationStrategy to the declarative component schema and its corresponding Pydantic model, allowing users to specify custom validation logic via a fully-qualified class name. The DpathValidator and PredicateValidator are updated to accept either the default or custom validation strategy. Factory logic is extended to support instantiating custom validation strategy components. Several union type orderings and field groupings are also standardized across models.

Changes

File(s) Change Summary
airbyte_cdk/sources/declarative/declarative_component_schema.yaml Added CustomValidationStrategy definition; updated DpathValidator.validation_strategy and PredicateValidator.validation_strategy to accept it; improved example formatting.
airbyte_cdk/sources/declarative/models/declarative_component_schema.py Added CustomValidationStrategy model; updated validation_strategy fields in DpathValidator and PredicateValidator; added cursor_datetime_formats and reordered fields in DatetimeBasedCursor; standardized union type orderings and field groupings; reformatted many fields with multi-line Field() calls.
airbyte_cdk/sources/declarative/parsers/model_to_component_factory.py Imported CustomValidationStrategyModel and mapped it to the custom component constructor in the factory.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant DeclarativeSchema
    participant ModelFactory
    participant CustomValidationClass

    User->>DeclarativeSchema: Defines DpathValidator with CustomValidationStrategy
    DeclarativeSchema->>ModelFactory: Passes CustomValidationStrategyModel
    ModelFactory->>CustomValidationClass: Instantiates custom validation via class_name
    CustomValidationClass-->>ModelFactory: Returns custom validator instance
    ModelFactory-->>DeclarativeSchema: Returns component with custom validation
Loading

Suggested labels

declarative-component-schema, airbyte-python-cdk

Suggested reviewers

  • lmossman

Would you like to add an example usage of the new CustomValidationStrategy in the documentation or a test to demonstrate its integration, 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 c473499 and 78857f2.

📒 Files selected for processing (1)
  • airbyte_cdk/sources/declarative/models/declarative_component_schema.py (15 hunks)
🧰 Additional context used
🪛 Pylint (3.3.7)
airbyte_cdk/sources/declarative/models/declarative_component_schema.py

[refactor] 1588-1588: Too few public methods (0/2)

(R0903)


[refactor] 1587-1587: Too few public methods (0/2)

(R0903)

⏰ Context from checks skipped due to timeout of 90000ms (9)
  • GitHub Check: Check: source-intercom
  • GitHub Check: Check: source-shopify
  • GitHub Check: Check: source-pokeapi
  • GitHub Check: Check: source-amplitude
  • GitHub Check: Check: source-hardcoded-records
  • GitHub Check: SDM Docker Image Build
  • GitHub Check: Pytest (Fast)
  • GitHub Check: Pytest (All, Python 3.11, Ubuntu)
  • GitHub Check: Pytest (All, Python 3.10, Ubuntu)
🔇 Additional comments (4)
airbyte_cdk/sources/declarative/models/declarative_component_schema.py (4)

1587-1598: LGTM! Clean implementation following established patterns.

The CustomValidationStrategy class is well-implemented and consistent with other custom component classes in the codebase. The description correctly references validation (not decoding as in the previous issue), and the example follows the expected naming convention.


1781-1785: Nice enhancement for datetime parsing flexibility!

The new cursor_datetime_formats field is a thoughtful addition that allows handling multiple datetime formats. The description clearly explains the relationship to the existing datetime_format field, wdyt?


2044-2044: Perfect integration of custom validation strategies!

Great work extending both DpathValidator and PredicateValidator to support the new CustomValidationStrategy. This maintains backward compatibility while enabling the custom validation functionality that's the core objective of this PR.

Also applies to: 2064-2064


1925-1925: Good standardization work across union types and field titles.

These consistency improvements help maintain a clean and organized schema structure. The union type reordering and more descriptive field titles (like distinguishing "HTTP Response Format" from "Download HTTP Response Format") enhance readability, wdyt?

Also applies to: 2303-2304, 2396-2396, 2413-2413, 2645-2645, 2665-2665, 2909-2909, 2925-2925, 2949-2949, 2965-2965

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

🧹 Nitpick comments (3)
airbyte_cdk/sources/declarative/parsers/model_to_component_factory.py (2)

225-227: Import block – alphabetical placement looks off
Nit: In this import cluster the entries are kept in alphabetical order. CustomValidationStrategy should come before CustomTransformation (V vs T). Would you like to move the new line up one spot to keep the ordering tidy, wdyt?

-from airbyte_cdk.sources.declarative.models.declarative_component_schema import (
-    CustomTransformation as CustomTransformationModel,
-)
+from airbyte_cdk.sources.declarative.models.declarative_component_schema import (
+    CustomTransformation as CustomTransformationModel,
+)
+from airbyte_cdk.sources.declarative.models.declarative_component_schema import (
+    CustomValidationStrategy as CustomValidationStrategyModel,
+)

689-689: Mapping entry added – consider doc-string update
Great to see CustomValidationStrategyModel wired in! Could we also update the class-level doc-string (or module docs) mentioning that custom validation strategies are now supported, so future readers spot the feature quickly, wdyt?

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

4207-4213: Example block is valid JSON but departs from the predominant YAML style – worth harmonising?

All other example snippets in the file are expressed in YAML. Sticking to one style keeps the docs easier to scan and avoids surprising users who copy-paste. Would you be open to re-writing this example as YAML (e.g. using the - name: notation), 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 8e36382 and 34f89fa.

📒 Files selected for processing (3)
  • airbyte_cdk/sources/declarative/declarative_component_schema.yaml (3 hunks)
  • airbyte_cdk/sources/declarative/models/declarative_component_schema.py (14 hunks)
  • airbyte_cdk/sources/declarative/parsers/model_to_component_factory.py (2 hunks)
🧰 Additional context used
🪛 Pylint (3.3.7)
airbyte_cdk/sources/declarative/models/declarative_component_schema.py

[refactor] 1590-1590: Too few public methods (0/2)

(R0903)


[refactor] 1589-1589: Too few public methods (0/2)

(R0903)

⏰ Context from checks skipped due to timeout of 90000ms (9)
  • GitHub Check: Check: source-shopify
  • GitHub Check: Check: source-pokeapi
  • GitHub Check: Check: source-hardcoded-records
  • GitHub Check: Check: source-amplitude
  • GitHub Check: Check: source-intercom
  • GitHub Check: Pytest (Fast)
  • GitHub Check: Pytest (All, Python 3.11, Ubuntu)
  • GitHub Check: Pytest (All, Python 3.10, Ubuntu)
  • GitHub Check: SDM Docker Image Build
🔇 Additional comments (4)
airbyte_cdk/sources/declarative/declarative_component_schema.yaml (1)

4360-4365: Addition of CustomValidationStrategy to the union looks good

The union now correctly accepts both built-in and custom strategies; no issues noticed here.

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

2046-2050: Nice enhancement to support custom validation strategies!

The union type update for validation_strategy correctly enables support for both the existing ValidateAdheresToSchema and the new CustomValidationStrategy. This change aligns perfectly with the PR objectives.


1927-1927: Great consistency improvements across union types!

The reordering of union types throughout the file standardizes the placement of custom components and improves overall consistency. These changes enhance maintainability without affecting functionality.

Also applies to: 2305-2306, 2398-2398, 2415-2415, 2667-2667, 2647-2647, 2911-2911, 2927-2927, 2951-2951, 2967-2967


1783-1821: Excellent improvements to field organization and clarity!

The field title updates in AsyncRetriever ("Decoder" → "HTTP Response Format") are much clearer and more descriptive. The DatetimeBasedCursor enhancements with the new cursor_datetime_formats field and improved field ordering enhance both functionality and usability.

Also applies to: 2911-2911, 2927-2927

Copy link

github-actions bot commented Jun 25, 2025

PyTest Results (Fast)

3 669 tests  ±0   3 658 ✅ ±0   6m 11s ⏱️ -4s
    1 suites ±0      11 💤 ±0 
    1 files   ±0       0 ❌ ±0 

Results for commit 78857f2. ± Comparison against base commit 8e36382.

♻️ This comment has been updated with latest results.

Copy link

PyTest Results (Full)

3 672 tests  ±0   3 661 ✅ ±0   17m 51s ⏱️ -8s
    1 suites ±0      11 💤 ±0 
    1 files   ±0       0 ❌ ±0 

Results for commit 78857f2. ± Comparison against base commit 8e36382.

@pnilan pnilan merged commit bfa4fb7 into main Jun 25, 2025
26 checks passed
@pnilan pnilan deleted the pnilan/validations/enable-custom-validation-strategies branch June 25, 2025 20:20
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.

2 participants