fix: Use backoff-provided exception instead of frame introspection - #607
Merged
Conversation
…ction python-backoff 3.0 changed its internal call stack, so the frame-walking hack in backoff_handler (a workaround for litl/backoff#158) started raising KeyError: "local variable ''e'' is not defined" and crashing retries. backoff 3.0 already resolved that upstream issue by passing the exception directly via details["exception"], so read it from there instead.
Avoids an unsafe cast on details["exception"] by narrowing it with isinstance(exc, RetriableAPIError) before accessing .response.
3 tasks
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.
Summary
error.log) showed 3 flaky test failures:KeyError: "local variable ''e'' is not defined", all frombackoff_handlerintap_github/client.py.backoff_handlerused a frame-introspection hack (walkingf_back.f_back.f_locals["e"]) to retrieve the exception object, working around litl/backoff#158 since olderbackoffversions didn't pass the exception toon_backoffhandlers.backoffisn't a direct dependency of tap-github — it's pulled in transitively viasinger-sdk, and the current lockfile happens to resolve it topython-backoff==3.0.0, whose internal call stack layout changed enough that the frame two levels up no longer has a local namede, causing the crash.DetailsTypedDict now includes anexceptionkey populated directly onon_backoff/on_giveupcalls, so the introspection hack is no longer needed.Changes
backoff_handlernow readsexc = details.get("exception")instead of frame-walking, and narrows it withisinstance(exc, RetriableAPIError)before accessing.response(avoiding an unsafecast).inspectimport andFrameTypetype-only import.Test plan
ruff check/ruff format --checkpass on the changed filetest_last_state_message_is_valid,test_get_a_repository_in_repo_list_mode[True/False]) locally — theKeyErrorno longer occurs (they now only fail on rate limiting due to no localGITHUB_TOKEN, unrelated to this fix)