Skip to content
This repository has been archived by the owner on Feb 24, 2024. It is now read-only.

Panic for http.FileSytem that returns non-os.ErrNotExist with ServeFiles #2057

Closed
duckbrain opened this issue Oct 25, 2020 · 2 comments
Closed
Labels

Comments

@duckbrain
Copy link
Contributor

Description

The filesystem router via app.ServeFiles doesn't check for non-os.ErrNotExist errors. This causes panics if a response returns a different error and a nil http.File. It appears to have a similar problem with Stat.

if os.IsNotExist(err) {

Steps to Reproduce the Problem

  1. Create a new project
  2. Replace the assetBox with a dummy one like the one below
  3. Go to an arbitrary route
type dummyFS struct{}

func (dummyFs) Open(string) (http.File, error) {
    return nil, errors.New("BOOM!")
}

Expected Behavior

I'm not sure what the best behavior would be to do here. Probably the built-in 500 error page. Alternatively it could log the error and skip to the next asset like it does if it returns os.ErrNotExist

Actual Behavior

Request panics, and client receives no response.

Info

-> Go: Checking installation
✓ The `go` executable was found on your system at: /usr/bin/go

-> Go: Checking minimum version requirements
✓ Your version of Go, 1.14.4, meets the minimum requirements.

-> Go: Checking Package Management
✓ You are using Go Modules (`go`) for package management.

-> Go: Checking PATH
✓ Your PATH contains /home/jonathan/.go/bin.

-> Node: Checking installation
✓ The `node` executable was found on your system at: /usr/bin/node

-> Node: Checking minimum version requirements
✓ Your version of Node, v14.14.0, meets the minimum requirements.

-> NPM: Checking installation
✓ The `npm` executable was found on your system at: /usr/bin/npm

-> NPM: Checking minimum version requirements
✓ Your version of NPM, 6.14.7, meets the minimum requirements.

-> Yarn: Checking installation
✓ The `yarnpkg` executable was found on your system at: /usr/bin/yarnpkg

-> Yarn: Checking minimum version requirements
✓ Your version of Yarn, 1.22.10, meets the minimum requirements.

-> PostgreSQL: Checking installation
✓ The `postgres` executable was found on your system at: /usr/bin/postgres

-> PostgreSQL: Checking minimum version requirements
✓ Your version of PostgreSQL, 12.4.0, meets the minimum requirements.

-> MySQL: Checking installation
✓ The `mysql` executable was found on your system at: /usr/bin/mysql

-> MySQL: Checking minimum version requirements
✓ Your version of MySQL, 15.1, meets the minimum requirements.

-> SQLite3: Checking installation
✓ The `sqlite3` executable was found on your system at: /usr/bin/sqlite3

-> SQLite3: Checking minimum version requirements
✘ Invalid Semantic Version

-> Cockroach: Checking installation
✘ The `cockroach` executable could not be found on your system.
For help setting up your Cockroach environment please follow the instructions for you platform at:

https://www.cockroachlabs.com/docs/stable/

-> Buffalo (CLI): Checking installation
✓ The `buffalo` executable was found on your system at: /home/jonathan/.go/bin/buffalo

-> Buffalo (CLI): Checking minimum version requirements
✓ Your version of Buffalo (CLI), v0.16.14, meets the minimum requirements.

-> Buffalo: Application Details
Pwd         /home/jonathan/src/git.duckfam.us/jonathan/test-project
Root        /home/jonathan/src/git.duckfam.us/jonathan/test-project
GoPath      /home/jonathan/.go
PackagePkg  test-project
ActionsPkg  test-project/actions
ModelsPkg   test-project/models
GriftsPkg   test-project/grifts
WithModules true
Name        test-project
Bin         bin/test-project
VCS         git
WithPop     true
WithSQLite  false
WithDep     false
WithWebpack false
WithNodeJs  true
WithYarn    true
WithDocker  true
WithGrifts  true
AsWeb       true
AsAPI       false
InApp       true
PackageJSON {map[build:vue-cli-service build dev:vue-cli-service serve lint:vue-cli-service lint serve:vue-cli-service serve test:unit:vue-cli-service test:unit]}

-> Buffalo: config/buffalo-app.toml
name = "test-project"
bin = "bin/test-project"
vcs = "git"
with_pop = true
with_sqlite = false
with_dep = false
with_webpack = false
with_nodejs = true
with_yarn = true
with_docker = true
with_grifts = true
as_web = true
as_api = false

-> Buffalo: config/buffalo-plugins.toml
[[plugin]]
  binary = "buffalo-pop"
  go_get = "github.com/gobuffalo/buffalo-pop/v2"

-> Buffalo: go.mod
module test-project

go 1.15

replace github.com/duckbrain/buffalo-vue => /home/jonathan/src/github.com/duckbrain/buffalo-vue

require (
	github.com/duckbrain/buffalo-vue v0.0.0-00010101000000-000000000000
	github.com/gobuffalo/buffalo v0.15.5
	github.com/gobuffalo/buffalo-pop/v2 v2.3.0
	github.com/gobuffalo/envy v1.9.0
	github.com/gobuffalo/mw-csrf v0.0.0-20190129204204-25460a055517
	github.com/gobuffalo/mw-forcessl v0.0.0-20180802152810-73921ae7a130
	github.com/gobuffalo/mw-i18n v0.0.0-20190129204410-552713a3ebb4
	github.com/gobuffalo/mw-paramlogger v0.0.0-20190129202837-395da1998525
	github.com/gobuffalo/packr/v2 v2.8.0
	github.com/gobuffalo/pop/v5 v5.3.0
	github.com/gobuffalo/suite v2.8.2+incompatible
	github.com/markbates/grift v1.5.0
	github.com/unrolled/secure v0.0.0-20190103195806-76e6d4e9b90c
)

@github-actions
Copy link

github-actions bot commented Aug 7, 2021

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

@github-actions
Copy link

This issue was closed because it has been stalled for 5 days with no activity.

@sio4 sio4 added the # chkme label Sep 26, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants