Repository navigation
fix: keep scalar json logs instead of dropping them - #812
Open
rootkiller6788 wants to merge 2 commits into
Open
rootkiller6788 wants to merge 2 commits into
rootkiller6788 wants to merge 2 commits into
Conversation
When LOG_EXECUTION_ID is set we rewrite every stdout/stderr write into a structured log entry, and we treated anything JSON.parse accepts as a log object to hang the labels off. Numbers, booleans, null and json strings parse fine but have no properties, so the 'in' check in getJSONWithContext threw and console silently swallowed it - the line the user logged just vanished. Only take the structured path for objects.
These four used to throw inside the logger and lose the log line. Also checked they fail on the previous commit.
rootkiller6788
marked this pull request as ready for review
November 8, 2026 12:57
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.
Found this while running a function with LOG_EXECUTION_ID=true. A plain
console.log(42)produced no log line at all, whileconsole.log('42')worked fine — the number just disappeared.The logger rewrites every stdout/stderr write into a structured log entry and decides "is this a structured log?" with a bare JSON.parse.
42,true,nulland"abc"all parse happily, so they were passed to getJSONWithContext, which does'logging.googleapis.com/labels' in jsonbefore setting anything.inon a primitive throws a TypeError, the write never happens, and node's console swallows the error, so the function keeps returning 200 and the user's log line is silently lost.Fix is to only treat the parsed value as a log object when it actually is one; numbers/booleans/null/strings now fall back to the plain text path that already handles non-JSON output.
Tested by calling getModifiedData directly (throws before, text output after) and end to end with a real server plus LOG_EXECUTION_ID=true, where the
42line now shows up with its execution_id. Added four regression cases to test/logger.ts and made sure they fail without the logger change.