Skip to content

fix(connector-builder): fix dynamic stream read with dynamic schema#534

Merged
lazebnyi merged 18 commits intomainfrom
lazebnyi/fix-dynamic-stream-read-with-dynamic-schema
May 13, 2025
Merged

fix(connector-builder): fix dynamic stream read with dynamic schema#534
lazebnyi merged 18 commits intomainfrom
lazebnyi/fix-dynamic-stream-read-with-dynamic-schema

Conversation

@lazebnyi
Copy link
Contributor

@lazebnyi lazebnyi commented May 7, 2025

What

The Connector Builder CDK, during execution of the read_stream command, listens to all logs and captures all outgoing requests, serializing them as part of the read stream process. As a result, dynamic schema loader calls (e.g., for dynamic_properties) are currently treated the same as regular stream reads. We need to update the log_formatter so that calls to dynamic_properties are marked as auxiliary.

How

Updated _fetch_next_page in SimpleRetrieverTestReadDecorator to set the is_auxiliary flag to True for streams named dynamic_properties.

Summary by CodeRabbit

  • New Features

    • Added the ability to enable or disable HTTP response logging for data retrieval operations.
    • Introduced customizable formatting for HTTP response logs.
  • Refactor

    • Improved the way log formatting is handled, allowing for greater flexibility and consistency in log output.

@github-actions github-actions bot added the bug Something isn't working label May 7, 2025
@lazebnyi lazebnyi requested a review from maxi297 May 7, 2025 11:35
@lazebnyi
Copy link
Contributor Author

lazebnyi commented May 7, 2025

/autofix

Auto-Fix Job Info

This job attempts to auto-fix any linting or formating issues. If any fixes are made,
those changes will be automatically committed and pushed back to the PR.

Note: This job can only be run by maintainers. On PRs from forks, this command requires
that the PR author has enabled the Allow edits from maintainers option.

PR auto-fix job started... Check job output.

✅ Changes applied successfully.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented May 7, 2025

📝 Walkthrough

Walkthrough

The changes introduce a customizable HTTP response log formatting mechanism in SimpleRetriever and its factory. A new optional log_formatter parameter is added to create_simple_retriever and used in dynamic schema loader creation. The SimpleRetriever class now supports a log_formatter attribute to control HTTP log formatting during requests.

Changes

File(s) Change Summary
airbyte_cdk/sources/declarative/parsers/model_to_component_factory.py Added import of Response and format_http_message; introduced log_formatter argument in create_simple_retriever and create_dynamic_schema_loader; replaced hardcoded retriever name with variable; passed log_formatter lambda for HTTP logging.
airbyte_cdk/sources/declarative/retrievers/simple_retriever.py Added optional log_formatter attribute to SimpleRetriever; removed inline HTTP log formatting lambda from _fetch_next_page; removed _fetch_next_page override in SimpleRetrieverTestReadDecorator to use base class implementation with configurable logging.
unit_tests/sources/declarative/retrievers/test_simple_retriever.py Updated test_emit_log_request_response_messages to assert existence and behavior of retriever.log_formatter directly instead of inspecting send_request call arguments.

Sequence Diagram(s)

sequenceDiagram
    participant Factory as ModelToComponentFactory
    participant SimpleRetriever
    participant Requester
    participant LogFormatter

    Factory->>SimpleRetriever: create_simple_retriever(..., log_formatter)
    alt log_formatter provided
        SimpleRetriever->>Requester: send_request(..., log_formatter)
        Requester->>LogFormatter: format_http_message(response)
    else no log_formatter
        SimpleRetriever->>Requester: send_request(..., log_formatter=None)
    end
Loading

Suggested labels

enhancement

Suggested reviewers

  • maxi297

Would you like to consider adding a test to explicitly cover the new log_formatter behavior, wdyt?

Tip

⚡️ Faster reviews with caching
  • CodeRabbit now supports caching for code and dependencies, helping speed up reviews. This means quicker feedback, reduced wait times, and a smoother review experience overall. Cached data is encrypted and stored securely. This feature will be automatically enabled for all accounts on May 16th. To opt out, configure Review - Disable Cache at either the organization or repository level. If you prefer to disable all data retention across your organization, simply turn off the Data Retention setting under your Organization Settings.

Enjoy the performance boost—your workflow just got faster.


📜 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 fe2b4aa and 0897f5f.

📒 Files selected for processing (1)
  • airbyte_cdk/sources/declarative/retrievers/simple_retriever.py (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • airbyte_cdk/sources/declarative/retrievers/simple_retriever.py
⏰ Context from checks skipped due to timeout of 90000ms (9)
  • GitHub Check: Check: 'source-pokeapi' (skip=false)
  • GitHub Check: Check: 'source-amplitude' (skip=false)
  • GitHub Check: Check: 'source-hardcoded-records' (skip=false)
  • GitHub Check: Check: 'source-shopify' (skip=false)
  • GitHub Check: Pytest (Fast)
  • GitHub Check: SDM Docker Image Build
  • GitHub Check: Pytest (All, Python 3.11, Ubuntu)
  • GitHub Check: Pytest (All, Python 3.10, Ubuntu)
  • 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 generate unit testing code for this file.
    • @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 generate unit testing code.
    • @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

@maxi297 maxi297 left a comment

Choose a reason for hiding this comment

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

Questions so that I understand a bit more the context

@lazebnyi lazebnyi requested review from brianjlai and maxi297 May 7, 2025 13:00
@lazebnyi lazebnyi force-pushed the lazebnyi/fix-dynamic-stream-read-with-dynamic-schema branch from a68cd5b to 7fdc9a4 Compare May 9, 2025 22:27
@lazebnyi
Copy link
Contributor Author

lazebnyi commented May 9, 2025

/autofix

Auto-Fix Job Info

This job attempts to auto-fix any linting or formating issues. If any fixes are made,
those changes will be automatically committed and pushed back to the PR.

Note: This job can only be run by maintainers. On PRs from forks, this command requires
that the PR author has enabled the Allow edits from maintainers option.

PR auto-fix job started... Check job output.

✅ Changes applied successfully.

@lazebnyi lazebnyi requested a review from bnchrch May 9, 2025 22:30
Copy link
Contributor

@maxi297 maxi297 left a comment

Choose a reason for hiding this comment

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

Do we need to instantiate the log_formatter for the DynamicSchemaResolver in order to pass the right format?

@lazebnyi
Copy link
Contributor Author

lazebnyi commented May 9, 2025

Do we need to instantiate the log_formatter for the DynamicSchemaResolver in order to pass the right format?

I'm not sure if we use this information anywhere, but I'm okay with adding it.

@lazebnyi
Copy link
Contributor Author

lazebnyi commented May 9, 2025

/autofix

Auto-Fix Job Info

This job attempts to auto-fix any linting or formating issues. If any fixes are made,
those changes will be automatically committed and pushed back to the PR.

Note: This job can only be run by maintainers. On PRs from forks, this command requires
that the PR author has enabled the Allow edits from maintainers option.

PR auto-fix job started... Check job output.

✅ Changes applied successfully.

@lazebnyi lazebnyi requested a review from maxi297 May 9, 2025 22:52
Copy link
Contributor

@maxi297 maxi297 left a comment

Choose a reason for hiding this comment

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

LGTM!

@lazebnyi
Copy link
Contributor Author

lazebnyi commented May 9, 2025

/autofix

Auto-Fix Job Info

This job attempts to auto-fix any linting or formating issues. If any fixes are made,
those changes will be automatically committed and pushed back to the PR.

Note: This job can only be run by maintainers. On PRs from forks, this command requires
that the PR author has enabled the Allow edits from maintainers option.

PR auto-fix job started... Check job output.

✅ Changes applied successfully.

@lazebnyi lazebnyi removed the request for review from bnchrch May 9, 2025 23:35
@lazebnyi lazebnyi merged commit 9ad1bc0 into main May 13, 2025
25 of 27 checks passed
@lazebnyi lazebnyi deleted the lazebnyi/fix-dynamic-stream-read-with-dynamic-schema branch May 13, 2025 15:41
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