Handle empty files#109
Merged
Merged
Conversation
Reviewer's GuideThis PR enhances the ELF loader to properly handle empty files by translating bare io.EOF errors into FormatError and extends the test suite and utilities to include and validate an empty-file scenario, along with a version bump. Sequence diagram for ELF loader handling empty filessequenceDiagram
participant "ELF Loader"
participant "debug_elf.Open()"
participant "Error Handler"
"ELF Loader"->>"debug_elf.Open()": Open file
"debug_elf.Open()"-->>"ELF Loader": io.EOF (if file is empty)
"ELF Loader"->>"Error Handler": Check error type
"Error Handler"-->>"ELF Loader": If io.EOF, wrap as FormatError
"ELF Loader"-->>"Caller": Return FormatError for empty file
Entity relationship diagram for new empty file test dataerDiagram
TESTDATA_PATH ||--o| TESTDATA : has
TESTDATA {
string Name
string Path
bool NonElf
Elf Elf
string StdErr
}
ELF {
string Name
string Path
EI_CLASS Class
Type Type
string Interpreter
string[] Dependencies
}
TESTDATA_PATH {
string Path
}
TESTDATA o|--|{ ELF : contains
Class diagram for updated TestDetails and TestCase structsclassDiagram
class TestDetails {
bool Lib
bool HasInterpreter
elf.Elf Elf
string StdErr
}
class TestCase {
string Src
string Dest
string[] ExpectedStdout
string[] ExpectedStderr
map[string]string ExpectedFiles
snaggle.Option[] Options
string[] Flags
}
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey there - I've reviewed your changes - here's some feedback:
- In TestData for P_empty, the Elf struct’s
Namefield is misspelled as “empyty”—updating it to “empty” will avoid confusion. - The nested asserts in TestInvalidElf can be simplified using require (or failing early) so that you don’t skip downstream checks when the primary error assertion fails.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- In TestData for P_empty, the Elf struct’s `Name` field is misspelled as “empyty”—updating it to “empty” will avoid confusion.
- The nested asserts in TestInvalidElf can be simplified using require (or failing early) so that you don’t skip downstream checks when the primary error assertion fails.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #109 +/- ##
==========================================
+ Coverage 76.47% 76.59% +0.12%
==========================================
Files 13 13
Lines 748 752 +4
==========================================
+ Hits 572 576 +4
Misses 119 119
Partials 57 57 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
workaround for golang/go#76338
Summary by Sourcery
Handle empty files as invalid ELF artifacts by mapping io.EOF to a FormatError and expanding tests and CLI behavior accordingly.
Bug Fixes:
Openon an empty file does not return a&FormatErrorgolang/go#76338 by converting io.EOF from empty files into a debug_elf.FormatError so they yield ErrInvalidElfEnhancements:
Tests:
Chores: