{"record":{"id":"5da3039ba21de44f","repo":"hashicorp/nomad","slug":"role-could-not-be-interpolated-with-args-w","errorCode":null,"errorMessage":"[✘] Role could not be interpolated with args: %w","messagePattern":"\\[✘\\] Role could not be interpolated with args: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"command/setup_vault.go","lineNumber":444,"sourceCode":"\treturn false\n}\n\nfunc (s *SetupVaultCommand) renderRole() (map[string]any, error) {\n\trole := map[string]any{}\n\terr := json.Unmarshal(vaultRoleBody, &role)\n\tif err != nil {\n\t\treturn role, fmt.Errorf(\"[✘] Role data could not be deserialized: %w\", err)\n\t}\n\n\trole[\"bound_audiences\"] = vaultAud\n\n\treturn role, nil\n}\n\nfunc (s *SetupVaultCommand) createRole(role map[string]any) error {\n\tbuf, err := json.Marshal(role)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"[✘] Role could not be interpolated with args: %w\", err)\n\t}\n\n\tpath := fmt.Sprintf(\"auth/%s/role/%s\", vaultPath, vaultRole)\n\n\t_, err = s.vLogical.WriteBytes(path, buf)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"[✘] Could not create Vault role: %w\", err)\n\t}\n\n\ts.Ui.Info(fmt.Sprintf(\"[✔] Created role %q.\", vaultRole))\n\treturn nil\n}\n\nfunc (s *SetupVaultCommand) policyExists() bool {\n\texistingPolicies, _ := s.vClient.Sys().ListPolicies()\n\treturn slices.Contains(existingPolicies, vaultPolicyName)\n}\n","sourceCodeStart":426,"sourceCodeEnd":462,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/command/setup_vault.go#L426-L462","documentation":"createRole in the Vault setup command marshals the role definition map to JSON before writing it to Vault's JWT auth role endpoint. This error wraps any json.Marshal failure, meaning the role map contains values that Go cannot serialize (e.g. channels, funcs, or unsupported types injected at runtime).","triggerScenarios":"json.Marshal(role) fails because the role map passed from Run contains a value of a non-JSON-serializable type (chan, func, complex) or an invalid UTF-8 structure.","commonSituations":"Programmatic customization of the role map (via custom code or a patched binary) inserting unsupported types; normally never triggered by CLI flags since flags produce strings/bools.","solutions":["Inspect the role map before marshaling and remove/convert unsupported value types","Ensure role values are only strings, bools, numbers, slices, and maps","Rebuild nomad-setup without local patches that alter the role map"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"buf, err := json.Marshal(role)\nif err != nil {\n    return fmt.Errorf(\"role config not JSON-serializable: %w\", err)\n}","typeGuard":null,"tryCatchPattern":"if _, err := json.Marshal(role); err != nil { /* inspect unsupported types */ }","preventionTips":["Only populate role maps with strings, bools, numbers, slices, maps","Never inject chan/func values into config maps","Add a unit test that marshals the default role map"],"tags":["go","json","vault","serialization"],"backgroundTag":"json-marshal-failed","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"}