Describe the bug
Multiple calls to ioutil.ReadAll() in fetcher/fetcher.go ignore returned errors, potentially leading to silent data loss or partial reads.
To reproduce
- Examine fetcher/fetcher.go line 137 in decodePart() function
- Examine fetcher/fetcher.go line 740 in attachment parsing
- Notice errors from ReadAll() are assigned to _ and ignored
Code locations:
Line 137:
body, _ := ioutil.ReadAll(reader) // Error ignored
return string(body), nil
Line 740:
b, _ := ioutil.ReadAll(p.Body) // Error ignored
Expected behavior
Errors from ReadAll() should be checked and propagated. If reading fails, function should return error rather than empty/partial data.
Additional context
- This is good first issue - straightforward error handling fix
- Side benefit: replace deprecated ioutil.ReadAll() with io.ReadAll() (deprecated since Go 1.16)
- Similar pattern exists in multiple locations
Suggested fix:
body, err := io.ReadAll(reader)
if err != nil {
return "", fmt.Errorf("failed to read body: %w", err)
}
return string(body), nil
Describe the bug
Multiple calls to ioutil.ReadAll() in fetcher/fetcher.go ignore returned errors, potentially leading to silent data loss or partial reads.
To reproduce
Code locations:
Line 137:
Line 740:
Expected behavior
Errors from ReadAll() should be checked and propagated. If reading fails, function should return error rather than empty/partial data.
Additional context
Suggested fix: