fix: prevent jq parse errors in setup script#624
Conversation
The setup script was experiencing intermittent "jq: parse error: Invalid numeric literal" errors when parsing neonctl output. This was caused by stderr contaminating stdout via 2>&1 redirects. Changes: - Remove 2>&1 redirects from all neonctl commands to keep JSON output clean - Add validate_json() helper to validate output before jq parsing - Add jq fallbacks (// empty) to handle API response variations - Add explicit empty checks for critical values like BRANCH_ID - Improve error messages to reference stderr output This makes the script less brittle by letting neonctl work as designed: JSON on stdout, errors on stderr. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
📝 WalkthroughWalkthroughA new JSON validation helper function is introduced in the Neon setup script, and the Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Possibly related PRs
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
📜 Recent review detailsConfiguration used: defaults Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🧰 Additional context used🧠 Learnings (1)📚 Learning: 2026-01-02T06:50:28.671ZApplied to files:
🧬 Code graph analysis (1).superset/setup.sh (1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
🔇 Additional comments (4)
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 |
🧹 Preview Cleanup CompleteThe following preview resources have been cleaned up:
Thank you for your contribution! 🎉 |
Problem
The setup script was experiencing intermittent
jq: parse error: Invalid numeric literal at line 1, column 8errors when parsing neonctl CLI output.Root cause: The
2>&1redirects were mixing neonctl's stderr (warnings/errors) with stdout (JSON), corrupting the JSON that jq expected to parse.Solution
Removed all
2>&1redirects - Let neonctl work as designed: JSON on stdout, errors on stderr.Added JSON validation - New
validate_json()helper validates output before jq parsing and shows raw output on failure.Added resilience - jq fallback syntax (
.branch.id // .id // empty) handles API response variations gracefully.Better error messages - Users see neonctl's actual errors plus contextual messages.
Changes
2>&1from all neonctl commands (4 locations)validate_json()helper functionBenefits
Testing
✅ Bash syntax validated with
bash -n✅ Code review of all modifications complete
The fix is backward compatible and doesn't change the script's functionality - just makes error handling more robust.
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.