Skip to content

Flusher fails to log: AttributeError: 'Response' object has no attribute 'exception' #25

Closed

Description

@nsbradford

logtail/flusher.py in step() at line 68

            if response.status_code == 500 and getattr(response, "exception") != None:
                print('Failed to send logs to Better Stack after {} retries: {}'.format(len(RETRY_SCHEDULE), response.exception))

Activity

  1. curusarn commented on Jun 13, 2024

    @curusarn
    Contributor

    Hey @nsbradford,

    Thank you for raising this!

    I'm passing this on to the team to reproduce and fix this.

    Could you share steps on how to reproduce the issue? 🙏
    It would help us fix this faster.

    Thank you for the report!

  2. nsbradford commented on Jul 12, 2024

    @nsbradford
    Author

    can't reliably reproduce, just happens occasionally 😅

  3. PetrHeinz commented on Sep 25, 2026

    @PetrHeinz
    Member

    Closing the loop on this one, sorry for the wait. The cause was in the flush worker's retry loop: after the last retry it read response.exception, which only exists on the stand-in object we create for connection errors. A genuine HTTP 500 from the server comes back as a real requests.Response, so the lookup raised AttributeError and killed the flush thread. The thread restarts on the next log record, which is why it only showed up occasionally and the traceback was the whole symptom.

    Fixed in 0.4.1 by #41, thanks to @jaideeppyne for the patch and the regression test with a real Response. If you are still on 0.3.x, upgrading should resolve it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions