{"record":{"id":"41dbf1f20ff7de2d","repo":"ipfs/kubo","slug":"invalid-type-s-must-be-one-of-direct-indirec","errorCode":null,"errorMessage":"invalid type '%s', must be one of {direct, indirect, recursive, all}","messagePattern":"invalid type '(.+?)', must be one of (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/commands/pin/pin.go","lineNumber":486,"sourceCode":"\t\t}\n\n\t\tif n.Pinning == nil {\n\t\t\treturn fmt.Errorf(\"pinning service not available\")\n\t\t}\n\n\t\ttypeStr, _ := req.Options[pinTypeOptionName].(string)\n\t\tstream, _ := req.Options[pinStreamOptionName].(bool)\n\t\tdisplayNames, _ := req.Options[pinNamesOptionName].(bool)\n\t\tname, _ := req.Options[pinNameOptionName].(string)\n\n\t\t// Validate name filter\n\t\tif err := cmdutils.ValidatePinName(name); err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\tmode, ok := pin.StringToMode(typeStr)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"invalid type '%s', must be one of {direct, indirect, recursive, all}\", typeStr)\n\t\t}\n\n\t\t// For backward compatibility, we accumulate the pins in the same output type as before.\n\t\tvar emit func(PinLsOutputWrapper) error\n\t\tlgcList := map[string]PinLsType{}\n\t\tif !stream {\n\t\t\temit = func(v PinLsOutputWrapper) error {\n\t\t\t\tlgcList[v.PinLsObject.Cid] = PinLsType{Type: v.PinLsObject.Type, Name: v.PinLsObject.Name}\n\t\t\t\treturn nil\n\t\t\t}\n\t\t} else {\n\t\t\temit = func(v PinLsOutputWrapper) error {\n\t\t\t\treturn res.Emit(v)\n\t\t\t}\n\t\t}\n\n\t\tif len(req.Arguments) > 0 {\n\t\t\terr = pinLsKeys(req, mode, displayNames || name != \"\", n.Pinning, api, emit)","sourceCodeStart":468,"sourceCodeEnd":504,"githubUrl":"https://github.com/ipfs/kubo/blob/329838acdfafae224582930457efe80aa217afc0/core/commands/pin/pin.go#L468-L504","documentation":"`ipfs pin ls` accepts a `--type` option restricted to direct, indirect, recursive, or all. The value is converted with `pin.StringToMode`; when it does not match any known mode, the command returns this formatted error naming the invalid value.","triggerScenarios":"`ipfs pin ls --type <bad>` with values like `recursive-`, `Recursive` (case-sensitive), `tree`, or a typo such as `recursve`; also RPC calls to `pin/ls` with an invalid `type` option.","commonSituations":"Typoed type values in scripts; assuming case-insensitivity; copying flags from older documentation or other tools that use different pin-type vocabularies.","solutions":["Use exactly one of: direct, indirect, recursive, all (lowercase).","Default to `--type=recursive` (the effective default) if unsure.","Validate the value in scripts before passing it to the command.","For status of all pins including through-relations, use `--type=all`."],"exampleFix":"// before\nclient.Request(\"pin/ls\").Option(\"type\", \"Recursive\").Send(ctx)\n// after\nclient.Request(\"pin/ls\").Option(\"type\", \"recursive\").Send(ctx)","handlingStrategy":"validation","validationCode":"var validTypes = map[string]bool{\"direct\": true, \"indirect\": true, \"recursive\": true, \"all\": true}\nif !validTypes[typeFlag] {\n    return fmt.Errorf(\"invalid pin type %q: use direct|indirect|recursive|all\", typeFlag)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always use lowercase pin type names","Centralize pin-type constants in scripts","Never feed user input straight into --type"],"tags":["ipfs","cli","pinning","invalid-argument"],"backgroundTag":"invalid-enum-value","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"}