fix: write errors to stdout when using -jsonl flag#1524
fix: write errors to stdout when using -jsonl flag#1524buildingvibes wants to merge 1 commit intoprojectdiscovery:devfrom
Conversation
Fixes projectdiscovery#611 When using -jsonl with -headless, errors were not being written to stdout, causing the output to be incomplete. This fix ensures that when JSON output is enabled, errors are written to stdout in addition to the error file (if configured), maintaining consistency with normal result output. Co-Authored-By: Claude Opus 4.6 <[email protected]>
WalkthroughThe Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~5 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
I've closed my other PRs to focus on this one per project contribution guidelines. |
dwisiswant0
left a comment
There was a problem hiding this comment.
How does adding new writer solve the underlying context deadline issue?
Mzack9999
left a comment
There was a problem hiding this comment.
As @dwisiswant0 pointed out, the issue seems related to a rot context handling
Summary
-jsonloption with-headlessoption results in error #611 where using-jsonlwith-headlesscaused errors to not be written to stdoutRoot Cause
The
WriteErrmethod inpkg/output/output.gowas only writing errors to the error file (if configured) but not to stdout, even when-jsonlflag was used. This caused inconsistent output behavior where normal results were written to stdout but errors were not.Solution
Modified
WriteErrto check if JSON output mode is enabled (w.json). When true, errors are now written to:gologger.Silent().Msgf()This ensures consistent behavior with the
Writemethod which already outputs to stdout in JSON mode.Test Results
Before Fix
After Fix
Backward Compatibility Verified
/claim #611
Summary by CodeRabbit
Release Notes