Fix/cache empty repolist error handling - #1209
Draft
EngCaioFonseca wants to merge 3 commits into
Draft
Conversation
Callbacks fire on initial page load with repo-choices still [], and psycopg2 renders an empty sequence as "()", so "WHERE repo_id in ()" errored on every fresh session. get_uncached returns [] early. retrieve_from_cache sends a NULL sentinel rather than returning early, since a bare DataFrame has no columns and twelve call sites preprocess on columns before testing df.empty. get_default_repo_with_data guards separately -- it indexes repo_ids[0].
run_query's bare except also caught KeyboardInterrupt/SystemExit and dropped the cause, so a timeout, a bad column and a dropped connection were indistinguishable. _bots.py logged the KeyError then fell through to an unbound dbm, raising NameError instead. caching_wrapper recorded bookkeeping for the full repolist rather than the repos it actually cached, adding a duplicate row per already-resident repo to the table the poll loops query twice a second. The stale name came from rebinding uncached_repos to the query vars; those are now separate.
Signed-off-by: Caio Fonseca <engcaiofonseca@protonmail.com>
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.
Pull Request Change Description
Summary
Fixes four issues in PostgreSQL data-access and startup error handling. The changes are local and introduce no schema, dependency, or callback-graph changes.
Changes
1. Handle empty repository selections
repo-choicesinitially contains[], but its callbacks still run. Psycopg2 converted the empty sequence intoIN (), causing invalid SQL during initial page loads.get_uncached()now returns[]immediately.retrieve_from_cache()usesIN (NULL)to return zero rows while preserving DataFrame columns.get_default_repo_with_data()now returnsNoneinstead of indexing an empty list.This is handled at the data and callback boundaries rather than with
prevent_initial_call, which would break navigation with selections restored from session storage.2. Preserve database error causes
AugurManager.run_query()previously caught every exception and discarded its cause.It now:
Exception, allowingKeyboardInterruptandSystemExitto propagate.raise ... from e.3. Preserve
_bots.pystartup failuresIf
AugurManager()failed,_bots.pycontinued with an uninitializeddbm, masking the original error withNameError.The original
KeyErrororSQLAlchemyErroris now logged and re-raised.4. Correct cache bookkeeping
caching_wrapper()recorded every requested repository, including repositories already cached. This created duplicate bookkeeping rows.Query parameters and uncached repository IDs now use separate variables, and bookkeeping records only repositories fetched by the current operation.
Result
Validation
Generative AI disclosure
Please select one option:
If AI tools were used, please provide details below:
- What tools were used? Claude Opus 5, GPT 5.6 - sol
- How were these tools used? Draft, multiple iterations, review.
- Did you review these outputs before submitting this PR? Yes.