{"record":{"id":"49d6731dba222a86","repo":"docker/cli","slug":"invalid-generic-resource-format-s-expected-nam","errorCode":null,"errorMessage":"invalid generic-resource format `%s` expected `name=value`","messagePattern":"invalid generic-resource format `(.+?)` expected `name=value`","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/command/service/generic_resource_opts.go","lineNumber":21,"sourceCode":"import (\n\t\"fmt\"\n\t\"strings\"\n\n\t\"github.com/docker/cli/cli/command/service/internal/genericresource\"\n\t\"github.com/moby/moby/api/types/swarm\"\n)\n\n// GenericResource is a concept that a user can use to advertise user-defined\n// resources on a node and thus better place services based on these resources.\n// E.g: NVIDIA GPUs, Intel FPGAs, ...\n// See https://github.com/moby/swarmkit/blob/de950a7ed842c7b7e47e9451cde9bf8f96031894/design/generic_resources.md\n\n// ValidateSingleGenericResource validates that a single entry in the\n// generic resource list is valid.\n// i.e 'GPU=UID1' is valid however 'GPU:UID1' or 'UID1' isn't\nfunc ValidateSingleGenericResource(val string) (string, error) {\n\tif strings.Count(val, \"=\") < 1 {\n\t\treturn \"\", fmt.Errorf(\"invalid generic-resource format `%s` expected `name=value`\", val)\n\t}\n\n\treturn val, nil\n}\n\n// ParseGenericResources parses an array of Generic resourceResources\n// Requesting Named Generic Resources for a service is not supported this\n// is filtered here.\nfunc ParseGenericResources(value []string) ([]swarm.GenericResource, error) {\n\tif len(value) == 0 {\n\t\treturn nil, nil\n\t}\n\n\tswarmResources, err := genericresource.Parse(value)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"invalid generic resource specification: %w\", err)\n\t}\n","sourceCodeStart":3,"sourceCodeEnd":39,"githubUrl":"https://github.com/docker/cli/blob/4f84911bfe8811e9b028e4b1fee8e7510be79387/cli/command/service/generic_resource_opts.go#L3-L39","documentation":"Returned by ValidateSingleGenericResource (generic_resource_opts.go:21) when an entry in the --generic-resource list contains no `=` character. Generic resources must be expressed as `name=value` (e.g. `GPU=2`); the validator simply counts `=` occurrences and rejects anything with fewer than one.","triggerScenarios":"Passing `docker service create --generic-resource \"GPU\" ...` (missing `=value`), or a malformed entry like `GPU:2` using a colon instead of equals.","commonSituations":"Confusing the `=` delimiter with `:` (common from YAML/compose habits), forgetting the value, or passing a bare resource name.","solutions":["Format each entry as name=value, e.g. `GPU=2`.","Replace any `:` or space delimiters with `=`.","Double-check compose-to-CLI translation of generic resource lists."],"exampleFix":"// before\ndocker service create --generic-resource \"GPU\" --name svc img\n// after\ndocker service create --generic-resource \"GPU=2\" --name svc img","handlingStrategy":"validation","validationCode":"// Validate each generic-resource entry has the name=value shape.\nfunc validateGenericResourceEntries(entries []string) error {\n    for _, e := range entries {\n        if strings.Count(e, \"=\") < 1 {\n            return fmt.Errorf(\"invalid generic-resource format %q expected name=value\", e)\n        }\n    }\n    return nil\n}","typeGuard":"// isNameValue reports whether entry matches the name=value shape.\nfunc isNameValue(entry string) bool { return strings.Count(entry, \"=\") >= 1 }","tryCatchPattern":null,"preventionTips":["Use the name=value convention consistently.","Avoid `:` as a delimiter for generic resources.","Validate entries in config loaders before deployment."],"tags":["service","generic-resource","swarm","validation","docker-cli"],"backgroundTag":null,"analyzedSha":"4f84911bfe8811e9b028e4b1fee8e7510be79387","analyzedAt":"2026-08-07T12:15:29.814Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}