Skip to content

net/http: http.FileServer returns 500 on "not a directory" error #49552

Closed
@jba

Description

@jba

go version devel +b7a85e000

linux/amd64

What did you do?

Tried to serve shared/icon/favicon.ico/static/shared/icon/favicon.ico with http.FileServer(http.FS(MY_STATIC_PATH)).

What did you expect to see?

404

What did you see instead?

500

Diagnosis

The toHTTPError function (in net/http/fs.go) treats anything other than ErrNotExist and ErrPermission as a 500. But here we have an invalid path—a path that doesn't exist—that happens to go through the existing file shared/icon/favicon.ico. It should treat that the same as ErrNotExist.

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions