Skip to content

feat: improve error message for empty package.json files#793

Merged
graphite-app[bot] merged 1 commit intomainfrom
feat/empty-file-error-message
Oct 31, 2025
Merged

feat: improve error message for empty package.json files#793
graphite-app[bot] merged 1 commit intomainfrom
feat/empty-file-error-message

Conversation

@Boshen
Copy link
Member

@Boshen Boshen commented Oct 31, 2025

Summary

Improves error messages for empty package.json files by returning a clear "File is empty" message instead of the cryptic "EOF while parsing a value at line 1 column 0".

Changes

  • Add empty file check in PackageJson::parse() for both simd and serde implementations
  • Return JSONError with "File is empty" message before attempting JSON parsing
  • Update tests to expect new error message
  • Add comprehensive test suite for various corrupted package.json scenarios

Error Message Improvement

Before:

EOF while parsing a value at line 1 column 0

After:

File is empty

Test Plan

  • ✅ All existing tests pass (150/150)
  • ✅ Added new test test_corrupted_package_json covering multiple scenarios:
    • Empty file
    • Null bytes
    • Trailing commas
    • Unclosed braces
    • Invalid escapes
  • ✅ Updated incorrect_description_file_2 test for new error message
  • ✅ Clippy passes with no warnings

🤖 Generated with Claude Code

@graphite-app
Copy link

graphite-app bot commented Oct 31, 2025

How to use the Graphite Merge Queue

Add the label merge to this PR to add it to the merge queue.

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

@codecov
Copy link

codecov bot commented Oct 31, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.61%. Comparing base (f413b96) to head (f74efe2).
⚠️ Report is 3 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #793      +/-   ##
==========================================
+ Coverage   93.59%   93.61%   +0.01%     
==========================================
  Files          17       17              
  Lines        3093     3100       +7     
==========================================
+ Hits         2895     2902       +7     
  Misses        198      198              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@codspeed-hq
Copy link

codspeed-hq bot commented Oct 31, 2025

CodSpeed Performance Report

Merging #793 will not alter performance

Comparing feat/empty-file-error-message (f74efe2) with main (1a8a766)1

Summary

✅ 10 untouched
⏩ 5 skipped2

Footnotes

  1. No successful run was found on main (f74efe2) during the generation of this report, so 1a8a766 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

  2. 5 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@Boshen Boshen force-pushed the feat/empty-file-error-message branch from d3c6060 to 0d3bdaa Compare October 31, 2025 06:36
@Boshen Boshen added the merge label Oct 31, 2025
Copy link
Member Author

Boshen commented Oct 31, 2025

Merge activity

## Summary

Improves error messages for empty package.json files by returning a clear "File is empty" message instead of the cryptic "EOF while parsing a value at line 1 column 0".

## Changes

- Add empty file check in `PackageJson::parse()` for both simd and serde implementations
- Return `JSONError` with "File is empty" message before attempting JSON parsing
- Update tests to expect new error message
- Add comprehensive test suite for various corrupted package.json scenarios

## Error Message Improvement

**Before:**
```
EOF while parsing a value at line 1 column 0
```

**After:**
```
File is empty
```

## Test Plan

- ✅ All existing tests pass (150/150)
- ✅ Added new test `test_corrupted_package_json` covering multiple scenarios:
  - Empty file
  - Null bytes
  - Trailing commas
  - Unclosed braces
  - Invalid escapes
- ✅ Updated `incorrect_description_file_2` test for new error message
- ✅ Clippy passes with no warnings

🤖 Generated with [Claude Code](https://claude.com/claude-code)
@graphite-app graphite-app bot force-pushed the feat/empty-file-error-message branch from 80dd821 to f74efe2 Compare October 31, 2025 06:57
@graphite-app graphite-app bot merged commit f74efe2 into main Oct 31, 2025
17 checks passed
@graphite-app graphite-app bot deleted the feat/empty-file-error-message branch October 31, 2025 07:01
@Boshen Boshen mentioned this pull request Oct 31, 2025
@graphite-app graphite-app bot removed the merge label Oct 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant