Commit d48bc09
fix(ci): Add robust JSON validation for npm-check-updates output
Fixed jq parse error in weekly dependency audit workflow.
Issue:
- Workflow failing with: jq: parse error: Invalid literal at line 1, column 6
- Error occurs when ncu --jsonUpgraded outputs invalid/empty JSON
Root Cause:
- ncu --jsonUpgraded may output non-JSON text when no upgrades available
- Direct piping to jq causes parse failures
Fix:
- Added JSON validation before parsing with jq
- Use 'jq empty' to validate JSON before counting
- Fallback to empty object {} and count=0 on any error
- Proper error handling with 2>/dev/null to suppress stderr
Testing:
- Handles ncu success with valid JSON
- Handles ncu success with invalid/empty output
- Handles ncu failures gracefully
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>1 parent 9925b0c commit d48bc09
1 file changed
Lines changed: 14 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
449 | 449 | | |
450 | 450 | | |
451 | 451 | | |
452 | | - | |
453 | 452 | | |
454 | | - | |
455 | | - | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
456 | 467 | | |
457 | 468 | | |
458 | 469 | | |
| |||
0 commit comments