{"record":{"id":"a6522c0116df6291","repo":"docker/cli","slug":"invalid-mode-specified-v","errorCode":null,"errorMessage":"invalid mode specified: %v","messagePattern":"invalid mode specified: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"opts/swarmopts/config.go","lineNumber":62,"sourceCode":"\t\tkey, val, ok := strings.Cut(field, \"=\")\n\t\tif !ok || key == \"\" {\n\t\t\treturn fmt.Errorf(\"invalid field '%s' must be a key=value pair\", field)\n\t\t}\n\n\t\t// TODO(thaJeztah): these options should not be case-insensitive.\n\t\tswitch strings.ToLower(key) {\n\t\tcase \"source\", \"src\":\n\t\t\toptions.ConfigName = val\n\t\tcase \"target\":\n\t\t\toptions.File.Name = val\n\t\tcase \"uid\":\n\t\t\toptions.File.UID = val\n\t\tcase \"gid\":\n\t\t\toptions.File.GID = val\n\t\tcase \"mode\":\n\t\t\tm, err := strconv.ParseUint(val, 0, 32)\n\t\t\tif err != nil {\n\t\t\t\treturn fmt.Errorf(\"invalid mode specified: %v\", err)\n\t\t\t}\n\n\t\t\toptions.File.Mode = os.FileMode(m)\n\t\tdefault:\n\t\t\treturn fmt.Errorf(\"invalid field in config request: %s\", key)\n\t\t}\n\t}\n\n\tif options.ConfigName == \"\" {\n\t\treturn errors.New(\"source is required\")\n\t}\n\tif options.File.Name == \"\" {\n\t\toptions.File.Name = options.ConfigName\n\t}\n\n\to.values = append(o.values, options)\n\treturn nil\n}","sourceCodeStart":44,"sourceCodeEnd":80,"githubUrl":"https://github.com/docker/cli/blob/4f84911bfe8811e9b028e4b1fee8e7510be79387/opts/swarmopts/config.go#L44-L80","documentation":"Thrown by ConfigOpt.Set (config.go:62) when the `mode` field cannot be parsed as an unsigned 32-bit integer. The file mode for the mounted config is parsed with strconv.ParseUint(val, 0, 32), which accepts decimal or 0-prefixed octal/hex. Non-numeric, out-of-range, or malformed mode values produce this wrapped error.","triggerScenarios":"Passing `--config source=c,mode=abc`, `mode=r--r--r--` (symbolic notation), `mode=99999999999` (overflow), or `mode=0xZZ`. ParseUint with base 0 fails, and the error is wrapped at line 62.","commonSituations":"Using symbolic chmod notation ('rw-r--r--') instead of numeric, forgetting the leading 0 for octal (`mode=644` is parsed as decimal 644 = octal 0o1204), or passing a permission string from another tool.","solutions":["Use numeric mode, preferably octal with leading 0: `--config source=c,mode=0440`.","If you want decimal, ensure it fits in uint32 and represents the intended bits.","Avoid symbolic notation; this parser does not understand 'rwx'.","Validate with `strconv.ParseUint(val, 0, 32)` before constructing the flag."],"exampleFix":"// before\n--config source=appconf,mode=r--r-----\n// after\n--config source=appconf,mode=0440","handlingStrategy":"validation","validationCode":"// Validate the config mode as a uint32 (base 0 → octal with 0 prefix) before Set.\nif _, err := strconv.ParseUint(modeVal, 0, 32); err != nil {\n    return fmt.Errorf(\"mode %q must be a numeric (octal with 0-prefix) uint32\", modeVal)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use octal with a leading 0: mode=0440.","Never use symbolic chmod notation.","Remember mode=640 is parsed as decimal unless prefixed with 0.","Validate with strconv.ParseUint(val, 0, 32) in your wrapper."],"tags":["docker","swarm","config","validation","file-permissions","cli"],"backgroundTag":null,"analyzedSha":"4f84911bfe8811e9b028e4b1fee8e7510be79387","analyzedAt":"2026-08-07T12:15:29.814Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}