{"record":{"id":"198156ce564df2a1","repo":"ipfs/kubo","slug":"invalid-type-s-must-be-one-of-direct-indirec-198156","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/coreiface/options/pin.go","lineNumber":180,"sourceCode":"func (pinLsOpts) Indirect() PinLsOption {\n\treturn Pin.Ls.pinType(\"indirect\")\n}\n\n// Type is an option for Pin.Ls which will make it only return pins of the given\n// type.\n//\n// Supported values:\n//   - \"direct\" - directly pinned objects\n//   - \"recursive\" - roots of recursive pins\n//   - \"indirect\" - indirectly pinned objects (referenced by recursively pinned\n//     objects)\n//   - \"all\" - all pinned objects (default)\nfunc (pinLsOpts) Type(typeStr string) (PinLsOption, error) {\n\tswitch typeStr {\n\tcase \"all\", \"direct\", \"indirect\", \"recursive\":\n\t\treturn Pin.Ls.pinType(typeStr), nil\n\tdefault:\n\t\treturn nil, fmt.Errorf(\"invalid type '%s', must be one of {direct, indirect, recursive, all}\", typeStr)\n\t}\n}\n\n// pinType is an option for Pin.Ls which allows to specify which pin types should\n// be returned\n//\n// Supported values:\n//   - \"direct\" - directly pinned objects\n//   - \"recursive\" - roots of recursive pins\n//   - \"indirect\" - indirectly pinned objects (referenced by recursively pinned\n//     objects)\n//   - \"all\" - all pinned objects (default)\nfunc (pinLsOpts) pinType(t string) PinLsOption {\n\treturn func(settings *PinLsSettings) error {\n\t\tsettings.Type = t\n\t\treturn nil\n\t}\n}","sourceCodeStart":162,"sourceCodeEnd":198,"githubUrl":"https://github.com/ipfs/kubo/blob/329838acdfafae224582930457efe80aa217afc0/core/coreiface/options/pin.go#L162-L198","documentation":"Pin.Ls's Type option only accepts the literal strings \"direct\", \"indirect\", \"recursive\", or \"all\" (\"all\" is the default). Any other string is rejected at option-construction time with this error, before any RPC call is made. It protects against typos and ensures the pin-type filter maps to a valid internal PinLsOption.","triggerScenarios":"Calling pinLsOpts.Type(\"recursive \") (trailing whitespace), Type(\"Recursive\") (wrong case), Type(\"all_pins\") or any string outside the four accepted values while building options for Pin.Ls.","commonSituations":"Passing user input from a CLI flag or HTTP query parameter straight into Type without normalizing; case mismatches from a UI dropdown mapping; older code using pin-type names from a different API that differ slightly from kubo's set.","solutions":["Use only one of \"direct\", \"indirect\", \"recursive\", \"all\" (lowercase, exact)","Trim and strings.ToLower user-supplied input before passing it to Type","Validate against the allowed set with a switch or slices.Contains before calling Type","Omit the Type option entirely to get the default \"all\" behavior"],"exampleFix":"// before\nopt, err := options.Pin.Ls.Type(\"Recursive\") // wrong case\n// after\nt := strings.ToLower(strings.TrimSpace(userInput))\nif !slices.Contains([]string{\"direct\",\"indirect\",\"recursive\",\"all\"}, t) {\n    return fmt.Errorf(\"unsupported pin type: %s\", t)\n}\nopt, err := options.Pin.Ls.Type(t)","handlingStrategy":"validation","validationCode":"var validPinTypes = []string{\"direct\", \"indirect\", \"recursive\", \"all\"}\nfunc validatePinType(s string) (string, error) {\n    s = strings.ToLower(strings.TrimSpace(s))\n    if !slices.Contains(validPinTypes, s) {\n        return \"\", fmt.Errorf(\"pin type must be one of %v\", validPinTypes)\n    }\n    return s, nil\n}","typeGuard":null,"tryCatchPattern":"opt, err := options.Pin.Ls.Type(t)\nif err != nil {\n    return fmt.Errorf(\"invalid pin ls type %q: %w\", t, err)\n}","preventionTips":["Always lowercase/trim user-supplied pin types before passing them to Type","Expose only the four valid values in UI dropdowns or CLI completions","Rely on the default \"all\" when no explicit filtering is needed"],"tags":["go","ipfs","pin","validation"],"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"}