{"record":{"id":"32addceb388bbd84","repo":"kataras/iris","slug":"unexpected-fsordir-argument-type-of-t-string-o","errorCode":null,"errorMessage":"unexpected \"fsOrDir\" argument type of %T (string or fs.FS or embed.FS or http.FileSystem)","messagePattern":"unexpected \"fsOrDir\" argument type of %T \\(string or fs\\.FS or embed\\.FS or http\\.FileSystem\\)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"context/fs.go","lineNumber":36,"sourceCode":"//\n// This package-level variable can be modified on initialization.\nvar ResolveFS = func(fsOrDir any) fs.FS {\n\tif fsOrDir == nil {\n\t\treturn noOpFS{}\n\t}\n\n\tswitch v := fsOrDir.(type) {\n\tcase string:\n\t\tif v == \"\" {\n\t\t\treturn noOpFS{}\n\t\t}\n\t\treturn os.DirFS(v)\n\tcase fs.FS:\n\t\treturn v\n\tcase http.FileSystem: // handles go-bindata.\n\t\treturn &httpFS{v}\n\tdefault:\n\t\tpanic(fmt.Errorf(`unexpected \"fsOrDir\" argument type of %T (string or fs.FS or embed.FS or http.FileSystem)`, v))\n\t}\n}\n\ntype noOpFS struct{}\n\nfunc (fileSystem noOpFS) Open(name string) (fs.File, error) { return nil, nil }\n\n// IsNoOpFS reports whether the given \"fileSystem\" is a no operation fs.\nfunc IsNoOpFS(fileSystem fs.FS) bool {\n\t_, ok := fileSystem.(noOpFS)\n\treturn ok\n}\n\ntype httpFS struct {\n\tfs http.FileSystem\n}\n\nfunc (f *httpFS) Open(name string) (fs.File, error) {","sourceCodeStart":18,"sourceCodeEnd":54,"githubUrl":"https://github.com/kataras/iris/blob/7bedaf55a0b64bbb2248a5845a2c60d81a30996a/context/fs.go#L18-L54","documentation":"This panic comes from iris's helper that converts a user-supplied asset source (a directory path string, fs.FS, embed.FS, or http.FileSystem) into an internal file system. It means the value passed was not one of the four accepted types, so the library cannot serve files from it.","triggerScenarios":"Calling an API such as HandleDir or EmbeddedDir-like helpers (context/FS-like conversion at context/fs.go) with a value whose type is not string, fs.FS, embed.FS, or http.FileSystem — e.g. passing a []byte, a custom type that merely embeds a string, or a pointer to a struct.","commonSituations":"Passing a byte slice of embedded assets instead of embed.FS; wrapping an embed.FS in a custom struct; using an older API signature after upgrading iris; passing a *os.File or directory object instead of its path string.","solutions":["Convert the argument to one of the accepted types: pass the directory path as a string, an fs.FS (e.g. os.DirFS(dir)), an embed.FS, or an http.FileSystem (e.g. http.FS(embedded) or httpfs from go-bindata).","If using embed, ensure you pass the embedded FS value itself (e.g. //go:embed assets; var assets embed.FS; then pass assets), not a wrapper struct.","Check the function signature you are calling to confirm which of the four types it expects."],"exampleFix":"// before\napp.HandleDir(\"/static\", myBytes) // []byte -> panic\n// after\napp.HandleDir(\"/static\", http.FS(myEmbedFS)) // or a path string / embed.FS","handlingStrategy":"validation","validationCode":"switch v.(type) {\ncase string, fs.FS, embed.FS, http.FileSystem:\n    // ok\ndefault:\n    panic(fmt.Sprintf(\"fsOrDir: unsupported type %T\", v))\n}","typeGuard":"func isFsOrDir(v interface{}) bool {\n    switch v.(type) {\n    case string, fs.FS, embed.FS, http.FileSystem:\n        return true\n    }\n    return false\n}","tryCatchPattern":null,"preventionTips":["Pass directory path strings or embed.FS directly, never wrappers","Wrap embed.FS with http.FS() when an http.FileSystem is expected","Check the API signature before passing custom types"],"tags":["panic","filesystem","type-mismatch"],"backgroundTag":"invalid-argument-type","analyzedSha":"7bedaf55a0b64bbb2248a5845a2c60d81a30996a","analyzedAt":"2026-08-30T20:38:16.250Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}