Repository navigation
fix(caddy-logs): parse OPNsense bracketless JSON lines - #1991
Open
hrithiksaini99 wants to merge 1 commit into
Open
hrithiksaini99 wants to merge 1 commit into
hrithiksaini99 wants to merge 1 commit into
Conversation
The stripped line retains its trailing braces (resp_headers close +
root close), so a plain prefix repair works; appending '}' would
unbalance it. Try '{"level":' + message first, then the
appended variant for daemons that also strip the trailing brace.
hrithiksaini99
force-pushed
the
fix/1935-caddy-bracketless-json
branch
from
November 7, 2026 08:11
d81aaae to
ab3f698
Compare
sabban
requested changes
Nov 13, 2026
sabban
left a comment
Contributor
There was a problem hiding this comment.
Hi, thank you for your contribution!
- The test fails:
UnmarshalJSONreturns an error on bad JSON, which stops the filter, so the||fallbacks never run. - Run
cscli hubtest run caddy-logsand regenerate the asserts instead of editing them. - Drop the appended-
}variant: the issue's line keeps its closing brace. - In #1935, could the reporter share the raw line (
evt.Line.Raw) and acquisition config? Standard OPNsense syslog formats parse fine on master, so the prefix is likely lost before the parser.
This branch has not been deployed
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
When Caddy logs arrive via OPNsense syslog/journald, the daemon strips the leading
{"level":prefix (leaving"info","ts":...), soUnmarshalJSONon the raw message fails and every such line is dropped.Fix
In the parser filter, retry the parse against
{"level": + messageas a fallback, then{"level": + message + }in case a daemon also strips the trailing brace. The fixture line keeps its trailing}}(verified viajson.loads: prepend-only repairs it, prepend+append does not), which is why prepend-only comes first. Intact lines are unaffected.Verification
New bracketless fixture line in
.tests/caddy-logs/from the issue (IP anonymized) + parsed/http_path assertions; stage counts bumped. Verified with pythonjson.loads: repaired line parses, raw line does not.Fixes #1935.