Guard non-object JSON log lines in discovery (PBM/mixed logs) - #2
Open
zelmario wants to merge 1 commit into
Open
Guard non-object JSON log lines in discovery (PBM/mixed logs)#2zelmario wants to merge 1 commit into
zelmario wants to merge 1 commit into
Conversation
…d logs)
_discover_log_file did `obj = json.loads(line)` then `obj.get("attr")`.
A log line can be valid JSON that is NOT an object — a bare quoted string
or number, common in PBM and mixed container logs. `.get` then raises
AttributeError, which isn't a JSONDecodeError, so it escapes the except
and aborts discovery for the whole file.
Guard the attr lookup with `isinstance(obj, dict)`. deep_discover already
no-ops on non-dict input, so bare-scalar lines are simply skipped.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This was referenced Jun 23, 2026
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.
Problem
_discover_log_fileparses each line and immediately readsobj.get("attr", {}):A log line can be valid JSON that is not an object — a bare quoted string or a number. These show up in PBM logs and other mixed container logs.
str/inthave no.get, so this raisesAttributeError, which is not aJSONDecodeError, so it escapes theexceptand aborts discovery for the entire file.Fix
Guard the
attrlookup withisinstance(obj, dict).deep_discoveralready no-ops on non-dict input, so bare-scalar lines are simply skipped (nothing to discover in them anyway).Verified: a file mixing a bare-string line, a number line, and a normal structured line now processes all lines without crashing.
🤖 Generated with Claude Code