{"record":{"id":"ad575711d6e72459","repo":"hashicorp/nomad","slug":"invalid-value-for-q-w","errorCode":null,"errorMessage":"invalid value for %q: %w","messagePattern":"invalid value for %q: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"client/hostvolumemanager/host_volume_plugin.go","lineNumber":195,"sourceCode":"\tfor param, val := range in {\n\t\tswitch param {\n\t\tcase \"mode\":\n\t\t\t// mode needs special treatment - it's octal. note that this does\n\t\t\t// not check whether it's a *reasonable* mode for a directory.\n\t\t\t// that will be discovered during MkdirAll and subsequent usage\n\t\t\t// by workloads (which we cannot predict).\n\t\t\tvar number uint64\n\t\t\tnumber, err = strconv.ParseUint(val, 8, 32)\n\t\t\tout.Mode = os.FileMode(number)\n\t\tcase \"uid\":\n\t\t\tout.Uid, err = strconv.Atoi(val)\n\t\tcase \"gid\":\n\t\t\tout.Gid, err = strconv.Atoi(val)\n\t\tdefault:\n\t\t\terr = fmt.Errorf(\"unknown mkdir parameter: %q\", param)\n\t\t}\n\t\tif err != nil {\n\t\t\treturn out, fmt.Errorf(\"invalid value for %q: %w\", param, err)\n\t\t}\n\t}\n\n\treturn out, nil\n}\n\nfunc (p *HostVolumePluginMkdir) Delete(_ context.Context, req *cstructs.ClientHostVolumeDeleteRequest) error {\n\tpath := filepath.Join(p.VolumesDir, req.ID)\n\tlog := p.log.With(\n\t\t\"operation\", \"delete\",\n\t\t\"volume_id\", req.ID,\n\t\t\"path\", path)\n\tlog.Debug(\"running plugin\")\n\n\terr := os.RemoveAll(path)\n\tif err != nil {\n\t\tlog.Error(\"error with plugin\", \"error\", err)\n\t\treturn err","sourceCodeStart":177,"sourceCodeEnd":213,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/client/hostvolumemanager/host_volume_plugin.go#L177-L213","documentation":"After reading each mkdir parameter, decodeMkdirParams converts its string value (strconv.Atoi for uid/gid, parsing for mode/path) and, if that conversion (or the unknown-parameter error from the default case) fails, returns this wrapped error naming the offending parameter. Note that the \"unknown mkdir parameter\" error from the default case is also routed through this wrapper, so this message can carry that cause too. It means a parameter key was recognized but its value could not be parsed into the expected numeric type.","triggerScenarios":"Calling Create with a params map where \"mode\", \"uid\", or \"gid\" has a non-numeric string value — e.g. mode \"rwxr-xr-x\", uid \"alice\", gid \"\" — or where an unrecognized key triggered the default-case error which is then wrapped as invalid value.","commonSituations":"Users passing symbolic permission strings instead of octal numbers; putting a username instead of a numeric uid; empty-string values from templating/variable interpolation leaving a parameter unset; misconfigured job variable producing \"0755\\n\" with stray whitespace.","solutions":["Supply numeric values: mode as an octal number string (e.g. \"0755\" or \"493\"), uid/gid as integer strings (e.g. \"1000\").","Check the %q in the wrapped message to see which parameter value failed, and inspect the raw value including hidden whitespace.","Fix templating so unset variables do not produce empty strings; validate inputs before calling Create.","If the cause is 'unknown mkdir parameter', rename the key per error 933's fix."],"exampleFix":"// before\nparams := map[string]string{\"path\": \"/vols/data\", \"mode\": \"rwxr-xr-x\", \"uid\": \"alice\"}\n\n// after\nparams := map[string]string{\"path\": \"/vols/data\", \"mode\": \"0755\", \"uid\": \"1000\"}","handlingStrategy":"validation","validationCode":"func validateMkdirValues(params map[string]string) error {\n    for _, k := range []string{\"mode\", \"uid\", \"gid\"} {\n        if v, ok := params[k]; ok {\n            if _, err := strconv.Atoi(v); err != nil {\n                return fmt.Errorf(\"parameter %q must be numeric, got %q\", k, v)\n            }\n        }\n    }\n    return nil\n}","typeGuard":null,"tryCatchPattern":"if err != nil && strings.Contains(err.Error(), \"invalid value for\") {\n    re := regexp.MustCompile(`invalid value for \"([^\"]+)\"`)\n    if m := re.FindStringSubmatch(err.Error()); m != nil {\n        log.Error(\"fix numeric value for parameter\", \"param\", m[0])\n    }\n}","preventionTips":["Always pass mode as an octal number string (e.g. \"0755\"), never symbolic notation.","Pass numeric uid/gid, never usernames; resolve names to IDs beforehand.","Guard templated values so unset variables never produce empty strings.","Trim whitespace on parameter values before submitting."],"tags":["validation","parameters","type-conversion","host-volumes","go"],"backgroundTag":"invalid-argument-value","analyzedSha":"482b49bf1aec006f089bcfc7e632d8f6ac303e5e","analyzedAt":"2026-09-04T07:54:14.808Z","contentChangedAt":"2026-09-04T07:54:14.808Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}