{"record":{"id":"3a1e7fe819dd998c","repo":"docker/cli","slug":"type-is-empty-must-be-one-of-s","errorCode":null,"errorMessage":"type is empty: must be one of \"%s\"","messagePattern":"type is empty: must be one of \"(.+?)\"","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/command/system/inspect.go","lineNumber":69,"sourceCode":"type inspectOptions struct {\n\tformat     string\n\tobjectType objectType\n\tsize       bool\n\tids        []string\n}\n\n// newInspectCommand creates a new cobra.Command for `docker inspect`\nfunc newInspectCommand(dockerCLI command.Cli) *cobra.Command {\n\tvar opts inspectOptions\n\n\tcmd := &cobra.Command{\n\t\tUse:   \"inspect [OPTIONS] NAME|ID [NAME|ID...]\",\n\t\tShort: \"Return low-level information on Docker objects\",\n\t\tArgs:  cli.RequiresMinArgs(1),\n\t\tRunE: func(cmd *cobra.Command, args []string) error {\n\t\t\topts.ids = args\n\t\t\tif cmd.Flags().Changed(\"type\") && opts.objectType == \"\" {\n\t\t\t\treturn fmt.Errorf(`type is empty: must be one of \"%s\"`, strings.Join(allTypes, `\", \"`))\n\t\t\t}\n\t\t\treturn runInspect(cmd.Context(), dockerCLI, opts)\n\t\t},\n\t\t// TODO(thaJeztah): should we consider adding completion for common object-types? (images, containers?)\n\t\tValidArgsFunction:     completeObjectNames(dockerCLI),\n\t\tDisableFlagsInUseLine: true,\n\t}\n\n\tflags := cmd.Flags()\n\tflags.StringVarP(&opts.format, \"format\", \"f\", \"\", flagsHelper.InspectFormatHelp)\n\tflags.StringVar(&opts.objectType, \"type\", \"\", \"Only inspect objects of the given type\")\n\tflags.BoolVarP(&opts.size, \"size\", \"s\", false, \"Display total file sizes if the type is container\")\n\n\t_ = cmd.RegisterFlagCompletionFunc(\"type\", completion.FromList(allTypes...))\n\n\treturn cmd\n}\n","sourceCodeStart":51,"sourceCodeEnd":87,"githubUrl":"https://github.com/docker/cli/blob/4f84911bfe8811e9b028e4b1fee8e7510be79387/cli/command/system/inspect.go#L51-L87","documentation":"Returned by 'docker inspect' when --type is explicitly set but its value is empty (e.g. --type ''). The command requires a non-empty value drawn from the supported object types when the flag is present.","triggerScenarios":"Running 'docker inspect --type \"\" <id>' or passing an empty --type from a script/variable. The guard at inspect.go:68-70 checks flags.Changed(\"type\") && opts.objectType == \"\".","commonSituations":"Shell variable expanded to empty ('$OBJ_TYPE' unset); typo '--type=' with nothing after; template/script bug feeding an empty type.","solutions":["Provide a concrete type from: container, image, network, node, plugin, secret, service, task, volume (or config).","If you don't want to filter by type, omit --type entirely.","Validate the variable is non-empty before passing it."],"exampleFix":"# before\nOBJ_TYPE=\"\"\ndocker inspect --type \"$OBJ_TYPE\" myid\n\n# after\nOBJ_TYPE=container\ndocker inspect --type \"$OBJ_TYPE\" myid\n# -or- omit the flag\ndocker inspect myid","handlingStrategy":"validation","validationCode":"// Reject empty --type when the flag is present\nif cmd.Flags().Changed(\"type\") && opts.objectType == \"\" {\n    return errors.New(\"--type must not be empty\")\n}","typeGuard":"func nonEmptyType(s string) bool {\n\treturn strings.TrimSpace(s) != \"\"\n}","tryCatchPattern":null,"preventionTips":["Default unset variables before passing to --type.","Omit --type when filtering is unnecessary.","Validate against the supported type list."],"tags":["inspect","flags","validation","type"],"backgroundTag":null,"analyzedSha":"4f84911bfe8811e9b028e4b1fee8e7510be79387","analyzedAt":"2026-08-07T12:15:29.814Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}