Log unknown severities and String or nil tags instead of raising - #51
Merged
Merged
Conversation
…/nil tags logger.unknown, add(nil, ...) and add(99, ...) raise KeyError "ANY", and a tags: field holding a String or nil raises TypeError. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Ruby's Logger formats UNKNOWN, nil and out-of-range severities as "ANY", which the formatter's SEVERITY_MAP didn't know. Map it to :unknown, and fall back to :unknown for any other label. Wrap tag: and tags: in Array() and skip nil tags. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
PetrHeinz
marked this pull request as ready for review
October 2, 2026 09:04
PetrHeinz
added a commit
that referenced
this pull request
Oct 2, 2026
Conflict in spec/logtail/logger_spec.rb: #51's describe "#unknown" and this branch's describe "#flush" were added at the same place. Both are kept, #unknown first. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.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.
logger.unknown("x"),logger.add(nil, "x")andlogger.add(99, "x")raiseKeyError: key not found: "ANY"from inside the formatter, so a call meant to log something crashes the caller instead. Ruby'sLoggerlabels UNKNOWN, a nil severity and anything above it "ANY", andFormatter::SEVERITY_MAPonly knows "UNKNOWN". A user fieldtags:holding a String or nil raisesTypeErrorfromArray#concatthe same way. The red-team probe against 0.1.20 printedunknown: KeyError: key not found: "ANY"for all three severity calls.SEVERITY_MAPmaps "ANY" to:unknown, and a label it doesn't know falls back to:unknowninstead of raising, just as Ruby'sLogger#format_severityfalls back to "ANY".tag:andtags:go throughArray(...), so a single String becomes a one-element list, and nil tags are skipped.Behaviour and compatibility:
unknown, or with the given tags. Documented calls are unchanged.tag: niland nils inside atags:array used to be sent asnulltags. They are now left out.tag:holding an Array is now flattened into the tags instead of being nested as a single element.Targets the logtail 0.1.21 patch release. No dependencies on the other open PRs.
The first commit only adds the tests and is expected to fail on CI; the fix follows in the next commit.
🤖 Generated with Claude Code