Skip to content

Report a batch Better Stack rejected instead of dropping it silently - #64

Merged
PetrHeinz merged 2 commits into
masterfrom
claude/report-rejected-batch
Nov 6, 2026
Merged

PetrHeinz merged 2 commits into
masterfrom
claude/report-rejected-batch

Conversation

@PetrHeinz

Copy link
Copy Markdown
Member

LogtailHandler retries a batch that Better Stack answers with a 5xx (or that hits a network error) and prints Failed to send logs to Better Stack after 3 retries: ... when the retries run out. A batch answered with any other non-2xx status is rightly not retried, but it is also dropped without a word: nothing is printed, nothing is raised and dropcount stays the same. An app with a wrong or revoked source token (401), or one sending a payload that is too large (413) or malformed (400, 422), gets no sign that none of its logs arrive.

With this change the flush worker reports such a batch through the same print() as the 5xx path:

Better Stack rejected 12 log records with HTTP 401 Unauthorized: {"errors":"Invalid source token"}. Further rejections with this status won't be reported.
  • The line names the number of records dropped, the HTTP status with its reason phrase, and the start of the response body (its first 200 characters on one line) when there is one.
  • It is printed once per HTTP status per flush worker. A batch is flushed every second, so a line per rejected batch would flood the output of a misconfigured app; a different status is reported again.
  • The retry policy and what counts as retryable stay as they are, and there is no new handler option.

The first commit adds only the tests and is expected to fail CI.

🤖 Generated with Claude Code

PetrHeinz and others added 2 commits November 5, 2026 20:08
…HTTP status

A 4xx answer (a wrong source token, a payload too large) drops the batch
without retrying it, and today without a word. These tests pin one printed
line per rejecting status, with the server's reason, and no retry.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A batch answered with a non-2xx status other than a 5xx is not retried, and
until now it was dropped without a word, so an app with a wrong source token
saw no sign that none of its logs arrived. The flush worker now prints one
line per HTTP status with the number of records dropped, the status and the
start of the server's answer, the way it reports a batch whose retries ran out.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@PetrHeinz
PetrHeinz marked this pull request as ready for review November 5, 2026 19:23
@PetrHeinz
PetrHeinz merged commit fdf2fb4 into master Nov 6, 2026
20 checks passed
@PetrHeinz
PetrHeinz deleted the claude/report-rejected-batch branch November 6, 2026 11:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant