fix: suppress noisy fake-useragent warning logs - #191
Open
boluwatifeajayi wants to merge 1 commit into
Open
Conversation
fake-useragent already recovers internally from cache-server failures, but logs the recovery as a warning with a full traceback attached. This repo's own get_rand_user_agent() is a second layer of defense on top of that, so the traceback was pure noise that led users to file bug reports for something that was never actually failing. Scoped the suppression to the fake_useragent logger only. Closes bisohns#159
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.
Closes #159
What's actually happening
This was never an unhandled crash.
fake-useragentalready recovers internally when its cache server is unreachable or returns unexpected data — it falls back to querying the server directly for JSON. But it logs that recovery as aWARNINGwith a full traceback attached (exc_info=exc), which looks alarming even though nothing failed.On top of that,
get_rand_user_agent()in this repo already wraps the whole thing in a try/except with its own static fallback list — a second layer of defense that was already working. The traceback users saw in #159 was pure log noise, not an actual bug (see the issue itself: the very next line shown is a successfulSearchResult).Fix
Suppressed
fake_useragent's own logger toERRORlevel, scoped strictly to that logger — nothing else in the dependency tree is touched.Testing
Added
tests/test_utils.pycoveringget_rand_user_agent():fake_useragent.UserAgentto force the internal failure pathWARNING-or-above log record reaches thefake_useragentloggerVerified the test actually catches a regression (not just passing vacuously) by temporarily reverting the suppression line and confirming the test fails, then restoring it.
Full suite: 43 passed (up from 42 baseline), pre-existing 4 failed/21 errors unchanged and unrelated (stale VCR cassettes, hostname-matcher mismatches — confirmed identical on baseline via
git stash).Scope note
Left
requirements/main.txt'sfake-useragent<0.2pin untouched. That ceiling excludes the entire 1.x/2.x rewrite (which removed the remote-server dependency causing this entirely) — a bigger, separate decision sincefake-useragentis now archived upstream.