fix: resolve startup crash from test import leak and silent retry data loss in invoke()#43
Open
xemishra wants to merge 1 commit into
Open
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
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
This PR fixes two bugs: one that crashes the app before it opens, and one
that silently drops API data during retry attempts.
Bug 1 - Startup Crash: Test Mock Imported at Production Module Level
File:
estimators/factory.pyMockUrlInvokerwas imported unconditionally at the top offactory.py:The
tests/package is not shipped in production installs or Docker images,so this raises an
ImportErrorthe moment the app loads - before the windoweven opens. No credentials are checked, no scan runs.
Fix: Deferred the import into
get_mock_url_invoker()with a clear errormessage explaining it is test-only. The factory now loads cleanly in all
environments.
Bug 2 - Silent Data Loss: Retry Logic Drops Requests in invoke()
File:
util/connectors.pyTwo issues in the
invoke()retry loop:Wrong source list for rebuild.
curr_batchwas filtered from itselfon each iteration rather than from the original
batch. Once a requestwas filtered out (due to an ID type mismatch), it could never re-enter
the retry queue even if retries remained.
ID type mismatch.
failed_response_idswas built as a plain listfrom response dicts whose
"id"may be a string, whilerequest["id"]is an int. The
incheck silently failed, socurr_batchbecame emptyand all retries were skipped with no log warning.
Broken f-string. The failure logger used nested quotes incompatible
with Python < 3.12, causing a
SyntaxErrorand swallowing the exceptionpath entirely.
Fix: Rebuilt
curr_batchfrom the originalbatchlist, used asetof
str-cast IDs for reliable membership testing, and corrected the loggerto safely format response IDs.
Testing
from estimators.factory import EstimatorFactorysucceedswithout the
tests/package present.from util.connectors import UrlInvokerparses cleanly onPython 3.10+.
Files Changed
estimators/factory.pyutil/connectors.py