-
-
Notifications
You must be signed in to change notification settings - Fork 103
Write [Shakapacker] log messages to stderr instead of stdout #869
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
Warning Rate limit exceeded
⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. WalkthroughThis PR redirects logging and progress messages from stdout to stderr across the runner and dev server runner to prevent informational output from polluting JSON output when using the Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 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 |
Greptile SummaryThis PR fixes a critical bug where Key Changes:
Impact:
Confidence Score: 5/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant User
participant Runner
participant Webpack/Rspack
participant stdout
participant stderr
User->>Runner: bin/shakapacker --profile --json
Runner->>stderr: [Shakapacker] Looking for config...
Runner->>stderr: [Shakapacker] Found config
Runner->>stderr: [Shakapacker] Preparing environment...
Runner->>stderr: [Shakapacker] Base command: ...
Runner->>stderr: [Shakapacker] Final command: ...
Runner->>Webpack/Rspack: Execute bundler command
Webpack/Rspack->>stdout: {"hash":"...","version":"...",...}
Runner->>stderr: [Shakapacker] Completed build in X.XXs
stdout->>User: Valid JSON (no log messages)
stderr->>User: Log messages visible in terminal
|
Code Review for PR #869Overall AssessmentThis PR successfully addresses issue #868 by fixing the JSON parsing problem when using Positive Findings1. Code Quality
2. Test Coverage
3. Standards Compliance
4. Performance & Security
Issues Found1. Incomplete Migration Found 4 additional puts statements with [Shakapacker] prefix that should be migrated to $stderr.puts for consistency in lib/shakapacker/runner.rb at lines 483-484 and 511-512 in the init_config_file and list_builds methods. 2. Other stdout Usage ℹ️ For your awareness, there are other uses of $stdout.puts in lib/shakapacker/dev_server_runner.rb and lib/tasks/shakapacker/*.rake files that appear to be error messages. These should likely also use $stderr.puts but are outside the scope of this PR. RecommendationsRequired for this PR:
Optional follow-up:
SummaryThis is a well-executed fix for a real issue. The only blocker is completing the migration for the remaining 4 puts statements to ensure consistency. Once that's addressed, this PR will be ready to merge. Great work on identifying and fixing this issue! 🎉 |
Code ReviewThis PR successfully addresses issue #868 by redirecting all ✅ StrengthsCode Quality:
Best Practices:
Test Coverage:
🔍 Potential ImprovementsMinor consideration (not blocking):
📊 Impact AssessmentPerformance: ✅ No impact 🎯 RecommendationApprove and merge after manual testing verification. This is a high-quality fix that:
Great work on this fix! 🚀 Reviewed with attention to: CLAUDE.md guidelines, RSpec testing patterns, Ruby style consistency |
8ff75d5 to
265dfe1
Compare
Code Review✅ Overall AssessmentThis is a well-executed fix that correctly addresses issue #868. The changes are focused, consistent, and properly tested. 🎯 Strengths
📋 Detailed ReviewProduction Code Changes ✅
All informational messages now use
Test Changes ✅
The test helper consolidation in 🔍 Code QualityNo Issues Found
🧪 Testing RecommendationsThe PR mentions manual testing as incomplete. I recommend: # Verify JSON output is clean
bin/shakapacker --profile --json > stats.json
cat stats.json | jq . # Should parse without errors
# Verify logs still appear on console
bin/shakapacker 2>&1 | grep "\[Shakapacker\]"This will confirm that:
📝 Minor Suggestion (Optional)Consider adding a brief note in the commit message or code comment explaining why stderr is used, for future maintainers: # Log to stderr to keep stdout clean for machine-readable output (e.g., --json flag)
$stderr.puts "[Shakapacker] Running build: #{build_config[:name]}"This is optional but could prevent future confusion. ✅ RecommendationLGTM - Approve and Merge This PR successfully fixes the reported issue without introducing any regressions. The implementation is clean, well-tested, and follows best practices. |
Code ReviewSummaryThis PR successfully addresses issue #868 by redirecting Shakapacker log messages from stdout to stderr, allowing tools like webpack-bundle-analyzer to properly parse JSON output from Strengths ✅
Issues & Recommendations 🔍1. Inconsistent stderr Usage for Version/Help OutputIssue: The
Question: Should
Recommendation: The current approach is fine. Version and help information should remain on stdout per Unix conventions. However, consider documenting this decision. 2. Other stdout Messages Not in ScopeSeveral other lib/shakapacker/dev_server_runner.rb:
lib/shakapacker/runner.rb:
lib/shakapacker/doctor.rb:
Assessment: These are error messages or user-facing command outputs (like Recommendation: Consider a follow-up issue to audit all output streams for consistency:
3. Missing Changelog EntryThe project guidelines indicate:
This is a bug fix (JSON output was broken) and changes observable behavior (log output stream), so it should have a changelog entry. Recommendation: Add a changelog entry: ### Fixed
- [PR #869](https://github.com/shakacode/shakapacker/pull/869): Write [Shakapacker] log messages to stderr instead of stdout by [justin808](https://github.com/justin808) - Fixes JSON output parsing when using `--json` flagOr use the 4. Test Coverage GapThe tests verify that log messages appear in stderr, but they don't verify that stdout is clean when using Recommendation: Consider adding a test that:
Example: it "produces valid JSON in stdout without log messages when using --json" do
# Mock system call and verify JSON output is clean
endThis would prevent regression of the exact bug being fixed. Code Quality ✅
Security & Performance ✅
ConclusionThis is a solid bug fix that solves the immediate problem. The implementation is clean and well-tested. Recommended Actions Before Merge:
Overall: Approve with minor suggestions - The core fix is correct, just needs changelog entry. Review generated by Claude Code |
- Add changelog entry for PR #869 documenting the bug fix - Add tests verifying [Shakapacker] log messages go to stderr, not stdout - Tests ensure stdout remains clean when using --json flag for valid JSON output Co-Authored-By: Claude Opus 4.5 <[email protected]>
Pull Request ReviewSummaryThis PR fixes issue #868 by redirecting all ✅ Code Quality & Best PracticesExcellent implementation with consistent changes:
Observation: Error messages were already using ✅ Bug Fixes & CorrectnessAll major issues addressed:
Test Coverage:
✅ Performance Considerations
✅ Security Considerations
🔍 Minor Observations
✅ Test Coverage AssessmentExcellent test coverage:
Recommendation: Before merging, manually verify the fix works as expected in a real Rails app. 📋 Final VerdictLGTM - Approve with confidence ✅ This is a well-implemented fix that:
No blocking issues found. The code is production-ready. 🎯 Suggestions for TestingPer CLAUDE.md requirements:
Great work on this fix! 🚀 |
Fixes #868. When using `bin/shakapacker --profile --json`, the [Shakapacker] log messages were being written to stdout, which broke JSON parsing tools like webpack-bundle-analyzer. Changed all informational log messages (prefixed with [Shakapacker]) to use $stderr.puts instead of puts, so that: - stdout remains clean for JSON output from webpack/rspack - log messages are still visible to users on stderr - tools that parse stdout get valid JSON Updated test files to capture stderr instead of stdout for tests that verify log output. Co-Authored-By: Claude Opus 4.5 <[email protected]>
- Add changelog entry for PR #869 documenting the bug fix - Add tests verifying [Shakapacker] log messages go to stderr, not stdout - Tests ensure stdout remains clean when using --json flag for valid JSON output Co-Authored-By: Claude Opus 4.5 <[email protected]>
0d6aca4 to
0b61ab6
Compare
Code ReviewOverviewThis PR successfully addresses issue #868 by redirecting ✅ Strengths
🔍 Issues Found1. Inconsistent Message Handling (Minor)There are 4 remaining lib/shakapacker/runner.rb:483-484: puts "[Shakapacker] Config file already exists: #{config_path}"
puts "Use --list-builds to see available builds"lib/shakapacker/runner.rb:511-512: puts "[Shakapacker] No config file found: #{loader.config_file_path}"
puts "Run 'bin/shakapacker --init' to create one"These are user-facing informational messages and should follow the same pattern as the rest of the codebase. They should be: $stderr.puts "[Shakapacker] Config file already exists: #{config_path}"
$stderr.puts "Use --list-builds to see available builds"and $stderr.puts "[Shakapacker] No config file found: #{loader.config_file_path}"
$stderr.puts "Run 'bin/shakapacker --init' to create one"2. Test Coverage for Edge Cases (Suggestion)Consider adding a test for the 📝 Code Quality
🔒 SecurityNo security concerns identified. This is purely an I/O redirection change. ⚡ PerformanceNo performance impact. The change only affects which file descriptor receives the output. 🧪 TestingThe test updates are particularly well done:
One minor observation: The tests mock 📋 RecommendationApprove with minor fix requested: Update the 4 remaining 🎯 Checklist
Great work overall! The fix is targeted, well-tested, and solves a real usability issue. 👍 |
Summary
Fixes #868. This PR changes all informational
[Shakapacker]log messages to be written to stderr instead of stdout.When running
bin/shakapacker --profile --json, the log messages were being written to stdout, which broke JSON parsing:This caused
SyntaxError: Unexpected token 'S', "[Shakapacke"... is not valid JSON.Changes
puts "[Shakapacker]..."statements to$stderr.puts "[Shakapacker]..."in:lib/shakapacker/runner.rblib/shakapacker/dev_server_runner.rbBehavior After This PR
--json)Test plan
bin/shakapacker --profile --json > stats.jsonshould produce valid JSON🤖 Generated with Claude Code
Summary by CodeRabbit
Release Notes
✏️ Tip: You can customize this high-level summary in your review settings.