fix(ftp): ProbeFTP returns wrong error when both SIZE and RETR fallback fail #136

Closed
opened 2026-07-13 18:03:30 +00:00 by the.auditor · 1 comment
Owner

internal/downloader/ftp.go:107-116 — When GetFTPFileSize fails, ProbeFTP falls back to conn.Retr(path). If the RETR fallback also fails, the function returns err (the original SIZE error), not retrErr (the actual failing operation).

This misleads debugging — the user sees a SIZE error when RETR was the actual failure.

size, err := GetFTPFileSize(conn, path)
if err != nil {
    _ = conn.Type(ftp.TransferTypeBinary)
    resp, retrErr := conn.Retr(path)
    if retrErr != nil {
        return nil, err   // ← should return retrErr or wrap both
    }
    ...
}

Discovered during review of PR #133.

`internal/downloader/ftp.go:107-116` — When `GetFTPFileSize` fails, `ProbeFTP` falls back to `conn.Retr(path)`. If the RETR fallback also fails, the function returns `err` (the original `SIZE` error), not `retrErr` (the actual failing operation). This misleads debugging — the user sees a `SIZE` error when `RETR` was the actual failure. ```go size, err := GetFTPFileSize(conn, path) if err != nil { _ = conn.Type(ftp.TransferTypeBinary) resp, retrErr := conn.Retr(path) if retrErr != nil { return nil, err // ← should return retrErr or wrap both } ... } ``` Discovered during review of PR #133.
Owner

Closing — fixed in PR #166. ProbeFTP returns retrErr instead of err when RETR fallback fails.

Closing — fixed in PR #[166](https://git.lan.thwap.org/thwap/pget/pulls/166). ProbeFTP returns retrErr instead of err when RETR fallback fails.
Sign in to join this conversation.
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
thwap/pget#136
No description provided.