Skip to content

Conversation

@devin-ai-integration
Copy link
Contributor

fix: propagate api_budget to parent streams in substream partition routers

Summary

This PR fixes issue airbytehq/oncall#9874 where api_budget configuration was not being applied to parent streams in parent-child stream scenarios, causing 403 rate limit errors.

Root Cause: When create_parent_stream_config_with_substream_wrapper creates a new ModelToComponentFactory instance for handling parent streams in SubstreamPartitionRouter scenarios, the global _api_budget was not being propagated to the new factory instance.

Fix: Added one line to propagate _api_budget from the parent factory to the substream factory, ensuring parent streams respect the same rate limiting configuration as child streams.

Changed Files:

  • airbyte_cdk/sources/declarative/parsers/model_to_component_factory.py (2 lines added)

Review & Testing Checklist for Human

This is a targeted fix with minimal code changes, but has medium confidence due to limited test coverage:

  • Critical: Test with an actual connector that uses substream partition routers (e.g., On24 source or similar) and verify that parent streams now respect api_budget configuration and no longer hit 403 rate limit errors
  • Verify that the existing test suite passes (pytest unit_tests/sources/declarative/parsers/test_model_to_component_factory.py)
  • Review that propagating _api_budget via direct field assignment is the correct approach (consistent with how other factory state is handled)
  • Check for any edge cases where this propagation could cause unintended behavior

Test Plan Recommendation

To verify the fix end-to-end:

  1. Create or use an existing declarative connector with:
    • Global api_budget configuration with a low rate limit (e.g., 29 requests/minute)
    • A child stream with SubstreamPartitionRouter that depends on a parent stream
  2. Run a sync and verify:
    • Parent stream respects the rate limit (should not exceed configured limit)
    • No 403 errors occur from exceeding API rate limits
    • Child stream correctly processes records from parent stream

Notes

  • Test Coverage Limitation: I attempted to add a unit test specifically for this scenario but encountered difficulties getting the test manifest structured correctly after 3 attempts. The fix passes existing tests (test_create_substream_partition_router and test_api_budget), but explicit test coverage for api_budget propagation to parent streams would be beneficial.
  • Related Issue: This is related to airbytehq/airbyte#53129 - "[low-code] Back-off strategy is not applied to parent streams"
  • Customer Impact: Tier 0/ICP-A customer (Invesco) experiencing this with On24 source v6.61.6

Session: https://app.devin.ai/sessions/14c6cca74bb741e782dfb81d6e2a2c50
Requested by: unknown () via /ai-fix command on oncall issue #9874

…uters

When parent streams are created for substream partition routers, a new
ModelToComponentFactory instance is created without the global _api_budget
being propagated. This causes parent streams to ignore rate limiting
configuration, leading to 403 errors when API rate limits are exceeded.

This fix ensures that the _api_budget is propagated to the new factory
instance so parent streams respect the same rate limiting configuration
as child streams.

Fixes airbytehq/oncall#9874

Co-Authored-By: unknown <>
@devin-ai-integration
Copy link
Contributor Author

Original prompt from API User
Comment from @agarctfi: /ai-fix\n\nIMPORTANT: The user will expect a response posted back to the PR. You should post exactly one comment back to the respective issue PR. If the user requested a code change or PR, your comment should contain a link to the PR. Assume the user has no access to your session or conversation thread unless/until you respond back to them.\n\nIssue #9874 by @bengineerdavis: Python: Custom Declarative 'On24' source `api_budget` configuration not being honored on parent stream - `maximum number of calls for this API`\n\nIssue URL: https://github.com/airbytehq/oncall/issues/9874\n\nPlease use playbook macro: !issue_fix

PLAYBOOK_md:
# AI Fix Playbook

You are AI Fix Devin, an expert at reproducing and fixing Airbyte-related issues.

## Context
You are working on the issue linked above in context. You will also need to pull issue comments for full context.

## Rule: Immediate Issue Comment After PR Creation
**MANDATORY REQUIREMENT**: If you create a PR during an AI Fix workflow, your **first action** after creating the PR must be to create a comment on the originating issue. If you cannot create a PR, likewise, your action should be to comment back to the issue.

## Properly note breaking changes

Types of breaking changes:
- spec change
    - a spec field is removed or renamed.
    - a new required spec field is added.
- schema change
    - a field is removed or renamed, or, the datatype is changed.
- stream or property removal
    - a stream is removed.
- state changes
    - the format of the state is changed.

Consult development guides for how to document in the metadata that a change is breaking (if so), and try to avoid breaking changes where necessary. Appropriate updates will also need to be made to the docs changelog and migration guide. Refer to the [Managing Breaking Changes in Connectors](https://docs.airbyte.com/platform/next/connector-development/connector-breaking-changes) documentation to understand what types of changes are cons... (3967 chars truncated...)

@devin-ai-integration
Copy link
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

@github-actions github-actions bot added bug Something isn't working security labels Nov 4, 2025
@github-actions
Copy link

github-actions bot commented Nov 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@devin/1762216217-fix-api-budget-parent-streams#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 devin/1762216217-fix-api-budget-parent-streams

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.

Co-Authored-By: unknown <>
@github-actions
Copy link

github-actions bot commented Nov 4, 2025

PyTest Results (Fast)

3 817 tests  ±0   3 805 ✅ ±0   6m 34s ⏱️ -9s
    1 suites ±0      12 💤 ±0 
    1 files   ±0       0 ❌ ±0 

Results for commit 48be581. ± Comparison against base commit 6504148.

@github-actions
Copy link

github-actions bot commented Nov 4, 2025

PyTest Results (Full)

3 820 tests   3 808 ✅  11m 13s ⏱️
    1 suites     12 💤
    1 files        0 ❌

Results for commit 48be581.

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.

1 participant