Repository navigation
feat(low-code): response-aware ConstantBackoffStrategy with fall-through on falsy renders - #1211
Draft
devin-ai-integration[bot] wants to merge 1 commit into
Draft
devin-ai-integration[bot] wants to merge 1 commit into
devin-ai-integration[bot] wants to merge 1 commit into
Conversation
…ckoffStrategy interpolation Co-Authored-By: bot_apk <apk@cognition.ai>
Contributor
Author
|
I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".
|
👋 Greetings, Airbyte Team Member!Here are some helpful tips and reminders for your convenience. 💡 Show Tips and TricksTesting This CDK VersionYou 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/1791298881-response-aware-constant-backoff#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/1791298881-response-aware-constant-backoffPR Slash CommandsAirbyte Maintainers can execute the following slash commands on your PR:
|
PyTest Results (Fast)5 050 tests +25 5 038 ✅ +25 11m 19s ⏱️ +15s Results for commit 9aef805. ± Comparison against base commit 5381b8f. This pull request removes 1 and adds 26 tests. Note that renamed tests count towards both. |
PyTest Results (Full)5 053 tests +25 5 041 ✅ +25 16m 10s ⏱️ + 3m 30s Results for commit 9aef805. ± Comparison against base commit 5381b8f. This pull request removes 1 and adds 26 tests. Note that renamed tests count towards both. |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
👉 TL;DR: Low-code connectors can now compute a constant retry wait from the failed response's body, headers or the retry attempt number. When the expression produces nothing, the strategy steps aside so the next configured backoff strategy handles the retry.
Specifically,
ConstantBackoffStrategy.backoff_time_in_secondsnow interpolatesresponse,headersandattempt_count(previously onlyconfig). Falsy, zero, non-numeric andUndefinedErrorrenders returnNonebefore jitter is applied.Resolves https://github.com/airbytehq/airbyte-internal-issues/issues/17716:
Close on merge: no. The issue is internally filed, but its acceptance criteria also require an SDM release and one adopter migration (https://github.com/airbytehq/airbyte-internal-issues/issues/17790 to https://github.com/airbytehq/airbyte-internal-issues/issues/17793).
Part of epic https://github.com/airbytehq/airbyte-internal-issues/issues/17704 (delivery step 1). The issue was requested by the AI-fix workflow (Devin Bot).
Changes
ConstantBackoffStrategy.backoff_time()evaluates the expression on every call with:configresponse: the parsed JSON body;{}when the body isn't JSON or the input is an exception/None(same semantic asHttpResponseFilter._safe_response_json). A JSON list is passed through as-is.headers: the response headers;{}on exception.attempt_countNonebefore jitter is applied when the render is falsy (None,"",0), comes out as0seconds, is non-numeric (a warning is logged), or raises jinjaUndefinedError(e.g.response.get(...)on a list body).DefaultErrorHandler/HttpClientthen fall through to the nextbackoff_strategiesentry or the default backoff. Other evaluation errors, such asZeroDivisionError, still propagate.declarative_component_schema.yamlchanges:interpolation_contextaddsresponse,headers,attempt_count.x-amzn-RateLimit-Limit) and pinterest (regex_search'Retry after N seconds' ormin(2 ** attempt_count, 120)).models/declarative_component_schema.py: only theConstantBackoffStrategyblock is updated, to match the schema. It was hand-edited becausepoe assemblewith the pinneddatamodel_code_generator==0.26.3causes unrelated churn across the repo.ModelToComponentFactoryneeded no change.Example from source-google-search-console, which would replace
LoadQuotaBackoffStrategy:Review Spotlight
Reviewers with limited time, please review first:
constant_backoff_strategy.py#L61-L107: the new context and the fall-through rules, including theUndefinedErrorcatchdeclarative_component_schema.yaml#L699: the documented examplesRisks / behavior changes
0+jitter_range_in_seconds: this used to returnrandom.uniform(0, 2*jitter)and never fell through. It now returnsNone. In the airbyte repo, only source-google-search-console sets jitter, and it uses a base of 60.0without jitter: this now returnsNoneinstead of0.0. Nothing observable changes, becauseDefaultErrorHandlerandHttpClientalready checkif backoff:.config) used to raiseValueError: could not convert string to float. It now logs a warning and falls through. This matches how the custom adopter classes andWaitTimeFromHeaderhandle unparseable values.Design decision: no
status_codein the contextLinkedInAdsDataVolumeBackoffStrategyalso checksstatus_code == 429, and the new context doesn't expose a status code. I kept the context the same asHttpResponseFilter(response,headers):If exact parity is needed, the 429 check can be expressed declaratively by giving 429 its own
DefaultErrorHandler(viaresponse_filterswithhttp_codes: [429]) inside aCompositeErrorHandler. Adding astatus_codevariable would be a small follow-up if reviewers prefer it.Follow-ups
REFRESH_TOKEN_THEN_RETRYfilter for it).Declarative-First Evaluation
N/A. This change is to the declarative framework itself: it extends the built-in
ConstantBackoffStrategyso connectors can drop custom components. No custom component is added.Test Coverage
New unit tests in
test_constant_backoff.pyandtest_default_error_handler.py. They cover:attempt_count-based (Pinterest) expressions.geton a list body0renders, with and without jitterRequestExceptionandNoneinputDefaultErrorHandlerfalling through to a second strategy (GSC 900 then 60 + jitter, and{{ 0 }}+ jitter falling through toExponentialBackoffStrategy)The 26 new tests fail on
mainand pass with the change. Locally,error_handlers/,test_model_to_component_factory.pyandtest_http_client.pyall pass (586 tests), andruff check,ruff format --checkandmypyon the touched module are clean.Link to Devin session: https://app.devin.ai/sessions/c1ef01a795c94eb3ae78f1aea714130f
Open in Devin Desktop: https://app.devin.ai/desktop/session/c1ef01a795c94eb3ae78f1aea714130f?variant=devin