Skip to content

Conversation

pedroslopez
Copy link
Contributor

@pedroslopez pedroslopez commented Sep 4, 2025

Initially I changed this type to be a string (differing from the one declared by the TestReader response) because that's what I was observing the type to be in my tests with simple manifests. Running in prod for real users I noticed an error when returning the response because the descriptor was actually a dict (as declared)

So, instead of overriding to string, this declares the type as a union to support both responses.

Summary by CodeRabbit

  • Refactor
    • Broadened the accepted format for slice descriptors in the API model to allow either a dictionary or a string.
    • Updated type hints to reflect the expanded input types.
    • No changes to runtime behavior or existing flows.
    • Existing configurations continue to work without modification.

@github-actions github-actions bot added the bug Something isn't working label Sep 4, 2025
Copy link

github-actions bot commented Sep 4, 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@pedro/fix-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 pedro/fix-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 build - Regenerate git-committed build artifacts, such as the pydantic models which are generated from the manifest JSON schema in YAML.
  • /poe <command> - Runs any poe command in the CDK environment

📝 Edit this welcome message.

Copy link

github-actions bot commented Sep 4, 2025

PyTest Results (Fast)

3 752 tests  ±0   3 740 ✅ ±0   6m 25s ⏱️ -4s
    1 suites ±0      12 💤 ±0 
    1 files   ±0       0 ❌ ±0 

Results for commit 30dc246. ± Comparison against base commit 5378cef.

Copy link

github-actions bot commented Sep 4, 2025

PyTest Results (Full)

3 755 tests  +3 755   3 743 ✅ +3 743   11m 0s ⏱️ + 11m 0s
    1 suites +    1      12 💤 +   12 
    1 files   +    1       0 ❌ ±    0 

Results for commit 30dc246. ± Comparison against base commit 5378cef.

@pedroslopez pedroslopez marked this pull request as ready for review September 4, 2025 14:34
@Copilot Copilot AI review requested due to automatic review settings September 4, 2025 14:34
Copy link
Contributor

coderabbitai bot commented Sep 4, 2025

📝 Walkthrough

Walkthrough

The typing for StreamReadSlices.slice_descriptor in airbyte_cdk/manifest_server/api_models/stream.py was expanded from Optional[str] to Optional[Union[Dict[str, Any], str]], and Union was added to imports. No runtime logic or control flow changes.

Changes

Cohort / File(s) Summary of Changes
API models typing update
airbyte_cdk/manifest_server/api_models/stream.py
Import updated to include Union; slice_descriptor type widened from Optional[str] to Optional[Union[Dict[str, Any], str]].

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Would you like to add a brief docstring or pydantic validator clarifying accepted shapes for slice_descriptor to guide downstream users, wdyt?

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch pedro/fix-type

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.
  • 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 the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

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

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore or @coderabbit 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

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • 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/manifest_server/api_models/stream.py (1)

62-62: Make slice_descriptor truly optional and consider accepting any mapping-like input

  • Default the field to None so Pydantic treats it as optional at validation time (it’s currently required despite the Optional annotation)
  • Optionally switch Dict[str, Any] to Mapping[str, Any] to accept mapping-like inputs beyond plain dicts
  • We ran a grep over all .slice_descriptor references and found no string-only operations (e.g., no .split, .upper, etc.), so widening to str or Mapping is safe
  • Can we confirm that our JSON Schema now emits oneOf: [string, object] for this field?

Proposed minimal diff:

-    slice_descriptor: Optional[Union[Dict[str, Any], str]]  # We're seeing strings at runtime
+    slice_descriptor: Optional[Union[Dict[str, Any], str]] = None  # We're seeing strings at runtime

Wdyt?

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 5378cef and 30dc246.

📒 Files selected for processing (1)
  • airbyte_cdk/manifest_server/api_models/stream.py (2 hunks)
⏰ 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). (1)
  • GitHub Check: Check: source-shopify
🔇 Additional comments (1)
airbyte_cdk/manifest_server/api_models/stream.py (1)

9-9: Import update looks good for 3.9+ compatibility

Adding Union here is the right call given the broadened annotation and the project’s likely Python version support. LGTM, wdyt?

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 fixes a type annotation issue in the manifest server API models where the slice_descriptor field was incorrectly typed as only accepting strings, when it can actually be either a dictionary or a string at runtime.

  • Updates the type annotation for slice_descriptor from Optional[str] to Optional[Union[Dict[str, Any], str]]

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@pedroslopez pedroslopez merged commit dd52cfe into main Sep 4, 2025
35 of 36 checks passed
@pedroslopez pedroslopez deleted the pedro/fix-type branch September 4, 2025 18:47
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.

1 participant