{"record":{"id":"42e5c1208bfbd451","repo":"gofiber/fiber","slug":"the-file-should-have-a-name","errorCode":null,"errorMessage":"the file should have a name","messagePattern":"the file should have a name","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"client/core.go","lineNumber":303,"sourceCode":"// releaseErrChan returns the error channel to the pool.\n// It's caller's responsibility to ensure that:\n// - the channel is not closed\n// - the channel is drained before returning it\n// - the channel is not reused after returning it\nfunc releaseErrChan(ch chan error) {\n\terrChanPool.Put(ch)\n}\n\n// newCore returns a new core object.\nfunc newCore() *core {\n\treturn &core{}\n}\n\nvar (\n\tErrTimeoutOrCancel      = errors.New(\"timeout or cancel\")\n\tErrURLFormat            = errors.New(\"the URL is incorrect\")\n\tErrNotSupportSchema     = errors.New(\"protocol not supported; only http or https are allowed\")\n\tErrFileNoName           = errors.New(\"the file should have a name\")\n\tErrBodyType             = errors.New(\"the body type should be []byte\")\n\tErrNotSupportSaveMethod = errors.New(\"only file paths and io.Writer are supported\")\n\tErrBodyTypeNotSupported = errors.New(\"the body type is not supported\")\n)\n","sourceCodeStart":285,"sourceCodeEnd":308,"githubUrl":"https://github.com/gofiber/fiber/blob/a105acad6c1e4576a77f01e02973f67e962bb58d/client/core.go#L285-L308","documentation":"Returned by writeMultipartBody (client/hooks.go:280) when iterating req.files and encountering a File whose Name and Path are both empty. The multipart writer needs at least one identifier to emit a Content-Disposition file part, so an empty File is rejected rather than silently dropped.","triggerScenarios":"Calling req.File(...) with an empty fiber.File{}; pushing a File where only FieldName was set; building the files slice programmatically and leaving Name/Path blank for one element; calling req.Files([]File{{FieldName: \"upload\"}}).","commonSituations":"Appending zero-value File structs from a loop that didn't populate fields; receiving file metadata from an upstream that omitted the filename; refactoring that swaps field order and leaves Name unset.","solutions":["Ensure every File in req.files has either Name or Path set before Send().","Filter empty entries out of the slice before passing it: slices.DeleteFunc(files, func(f File) bool { return f.Name == \"\" && f.Path == \"\" }).","When uploading from disk, set Path so the binder derives Name from filepath.Base(Path) (see hooks.go:284-287).","Validate the files slice in a helper before sending."],"exampleFix":"// before\nreq.File(fiber.File{FieldName: \"upload\"}) // no Name or Path -> ErrFileNoName\n\n// after\nreq.File(fiber.File{FieldName: \"upload\", Name: \"report.csv\", Body: data})","handlingStrategy":"validation","validationCode":"func sanitizeFiles(files []fiber.File) []fiber.File {\n    return slices.DeleteFunc(files, func(f fiber.File) bool {\n        return f.Name == \"\" && f.Path == \"\"\n    })\n}","typeGuard":"func hasNameOrPath(f fiber.File) bool { return f.Name != \"\" || f.Path != \"\" }","tryCatchPattern":"if err := req.Send(); err != nil {\n    if errors.Is(err, fiber.ErrFileNoName) {\n        // filter the files slice and retry\n    }\n}","preventionTips":["Validate every File in the slice before sending.","When uploading from disk, set Path so Name is derived automatically.","Write a helper that builds File structs and asserts Name is non-empty."],"tags":["client","multipart","upload","files","http"],"backgroundTag":null,"analyzedSha":"a105acad6c1e4576a77f01e02973f67e962bb58d","analyzedAt":"2026-08-11T17:33:26.942Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}