Title: Fix flush thread crashing (AttributeError) on a real server HTTP 500 by jaideeppyne · Pull Request #41 · logtail/logtail-python · GitHub
Open Graph Title: Fix flush thread crashing (AttributeError) on a real server HTTP 500 by jaideeppyne · Pull Request #41 · logtail/logtail-python
X Title: Fix flush thread crashing (AttributeError) on a real server HTTP 500 by jaideeppyne · Pull Request #41 · logtail/logtail-python
Description: Summary Fixes #25. FlushWorker.step decides whether to log an upload failure with: if response.status_code == 500 and getattr(response, "exception") != None: getattr(response, "exception") is called without a default. The two things step can receive are asymmetric: On a network error, Uploader.__call__ catches requests.RequestException and returns Fake500(e) — which has an .exception attribute. On a genuine server HTTP 500, session.post(...) returns a real requests.Response — which has no .exception attribute. So on a real 500, status_code == 500 is True, then getattr(response, "exception") raises AttributeError. That propagates out of step() → run(), so the background flush thread dies. Every subsequent log is enqueued but never sent for the rest of the process — silent log loss. This matches the reporter's "happens occasionally" (real 500s are intermittent). Fix - if response.status_code == 500 and getattr(response, "exception") != None: + if response.status_code == 500 and getattr(response, "exception", None) is not None: A real Response now yields None and skips the branch; the network-error Fake500 path still logs its exception as before. (Also switched != None → is not None to match idiom.) Tests Two regression tests in tests/test_flusher.py: test_step_does_not_crash_on_real_server_500 — returns a real requests.Response with status_code = 500; step() must not raise. This fails on the current code with the exact AttributeError: 'Response' object has no attribute 'exception' from #25. test_step_still_logs_network_error_fake500 — the Fake500 network-error path still logs. ⚠️ Worth noting: the existing tests use mock.MagicMock(status_code=500), and MagicMock auto-vivifies .exception, which is why they never caught this — the new test deliberately uses a real Response. Full tests/test_flusher.py suite passes (11 tests).
Open Graph Description: Summary Fixes #25. FlushWorker.step decides whether to log an upload failure with: if response.status_code == 500 and getattr(response, "exception") != None: getattr(response, "excep...
X Description: Summary Fixes #25. FlushWorker.step decides whether to log an upload failure with: if response.status_code == 500 and getattr(response, "exception") != None: getattr(response, &am...
Opengraph URL: https://github.com/logtail/logtail-python/pull/41
X: @github
Domain: github.com
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:14d9e821-e9c5-a002-b98e-efc96f8d1ff3 |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | AB18:7F3F9:23E612:312F37:6AFBB020 |
| html-safe-nonce | 000873a7a24a0093cfb5b39ef4a45429f31f02e8e5893c3790355276470d35fd |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBQjE4OjdGM0Y5OjIzRTYxMjozMTJGMzc6NkFGQkIwMjAiLCJ2aXNpdG9yX2lkIjoiMjM3OTY3ODMwNDg5NTIxNzY5NiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | ca398c52b3a0deabc7d3973dd4bcab7ead90c4d597b348c073936dde385dc8f6 |
| hovercard-subject-tag | pull_request:4301854478 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/logtail/logtail-python/pull/41/files |
| twitter:image | https://avatars.githubusercontent.com/u/25899506?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/25899506?s=400&v=4 |
| og:image:alt | Summary Fixes #25. FlushWorker.step decides whether to log an upload failure with: if response.status_code == 500 and getattr(response, "exception") != None: getattr(response, "excep... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | e25fbd830d3e6ad0e8935c105cf4fdc70c593dffcd27bb45b790ae4fece5ea55 |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/logtail/logtail-python git https://github.com/logtail/logtail-python.git |
| octolytics-dimension-user_id | 78922349 |
| octolytics-dimension-user_login | logtail |
| octolytics-dimension-repository_id | 351343852 |
| octolytics-dimension-repository_nwo | logtail/logtail-python |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 351343852 |
| octolytics-dimension-repository_network_root_nwo | logtail/logtail-python |
| turbo-body-classes | logged-out env-production page-responsive full-width |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 08c8f17f9d27054a108b8b6254e405de0151f660 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width