{"record":{"id":"371ab65c303198c8","repo":"ipfs/kubo","slug":"s-was-not-a-file","errorCode":null,"errorMessage":"%s was not a file","messagePattern":"(.+?) was not a file","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/commands/files.go","lineNumber":851,"sourceCode":"\tRun: func(req *cmds.Request, res cmds.ResponseEmitter, env cmds.Environment) error {\n\t\tnd, err := cmdenv.GetNode(env)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\tpath, err := checkPath(req.Arguments[0])\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\tfsn, err := mfs.Lookup(nd.FilesRoot, path)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"%s: %w\", path, err)\n\t\t}\n\n\t\tfi, ok := fsn.(*mfs.File)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"%s was not a file\", path)\n\t\t}\n\n\t\trfd, err := fi.Open(req.Context, mfs.Flags{Read: true})\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\tdefer rfd.Close()\n\n\t\toffset, _ := req.Options[offsetOptionName].(int64)\n\t\tif offset < 0 {\n\t\t\treturn fmt.Errorf(\"cannot specify negative offset\")\n\t\t}\n\n\t\tfilen, err := rfd.Size()\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}","sourceCodeStart":833,"sourceCodeEnd":869,"githubUrl":"https://github.com/ipfs/kubo/blob/329838acdfafae224582930457efe80aa217afc0/core/commands/files.go#L833-L869","documentation":"Fired by `ipfs files read` after an MFS lookup succeeds but the node at the given path is not an *mfs.File — i.e. it is a directory (or another non-file MFS node). Reading requires a regular UnixFS file, so the command refuses; the user passed a directory path to a read-style operation.","triggerScenarios":"Thrown at core/commands/files.go:851 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["List the directory with 'ipfs files ls <path>' and read one of its files","Use 'ipfs ls' or gateway-style listing for directory contents instead"],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"329838acdfafae224582930457efe80aa217afc0","analyzedAt":"2026-09-03T18:30:52.135Z","contentChangedAt":"2026-09-03T18:30:52.135Z","schemaVersion":2},"datasetVersion":"2026-09-11T00:17:11.886Z"}