Skip to content

BUG: Unchecked io.ReadAll() errors in fetcher.go #713

@andrinoff

Description

@andrinoff

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

  1. Examine fetcher/fetcher.go line 137 in decodePart() function
  2. Examine fetcher/fetcher.go line 740 in attachment parsing
  3. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggood first issueGood for newcomers

    Type

    No type

    Projects

    Status

    In review

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions