{"record":{"id":"4ccc51ea854b35cb","repo":"SigNoz/signoz","slug":"errcoderoleinvalidinput-4ccc51","errorCode":"ErrCodeRoleInvalidInput","errorMessage":"name is missing from the request","messagePattern":"name is missing from the request","errorType":"validation","errorClass":"errors SigNozError","httpStatus":400,"severity":"error","filePath":"pkg/types/authtypes/role.go","lineNumber":178,"sourceCode":"\t\treturn errors.Newf(errors.TypeInvalidInput, ErrCodeRoleInvalidInput, \"cannot edit/delete managed role: %s\", role.Name)\n\t}\n\n\treturn nil\n}\n\nfunc (role *PostableRole) UnmarshalJSON(data []byte) error {\n\tshadow := struct {\n\t\tName              string           `json:\"name\"`\n\t\tDescription       string           `json:\"description\"`\n\t\tTransactionGroups *json.RawMessage `json:\"transactionGroups\"`\n\t}{}\n\n\tif err := json.Unmarshal(data, &shadow); err != nil {\n\t\treturn err\n\t}\n\n\tif shadow.Name == \"\" {\n\t\treturn errors.New(errors.TypeInvalidInput, ErrCodeRoleInvalidInput, \"name is missing from the request\")\n\t}\n\n\tif match := roleNameRegex.MatchString(shadow.Name); !match {\n\t\treturn errors.New(errors.TypeInvalidInput, ErrCodeRoleInvalidInput, \"name must contain only lowercase letters (a-z) and hyphens (-), and be at most 50 characters long.\")\n\t}\n\n\tif strings.HasPrefix(shadow.Name, managedRolePrefix) {\n\t\treturn errors.Newf(errors.TypeInvalidInput, ErrCodeRoleInvalidInput, \"role name cannot start with %q as it is reserved for SigNoz managed roles.\", managedRolePrefix)\n\t}\n\n\tvar transactionGroups TransactionGroups\n\tif shadow.TransactionGroups != nil {\n\t\tvar err error\n\t\ttransactionGroups, err = NewTransactionGroups(*shadow.TransactionGroups)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t}","sourceCodeStart":160,"sourceCodeEnd":196,"githubUrl":"https://github.com/SigNoz/signoz/blob/5069bf80b08f1f00d7e014eccc09902f9871004f/pkg/types/authtypes/role.go#L160-L196","documentation":"Thrown in RoleRequest UnmarshalJSON when creating a role and the name field is missing or empty. Role names are the primary identifier, so they are mandatory on create.","triggerScenarios":"POST /api/v1/roles (or equivalent) with a JSON body lacking \"name\" or with \"name\": \"\".","commonSituations":"Client sends a partial update payload to the create endpoint, or a typo like \"Name\" instead of \"name\" (JSON tags are lowercase).","solutions":["Include a non-empty \"name\" field in the create-role request body","Check casing: the field is lowercase \"name\" per the JSON tag","Use the PATCH/update endpoint when you only want to change other fields"],"exampleFix":"// before\n{\"description\": \"view-only role\"}\n// after\n{\"name\": \"view-only\", \"description\": \"view-only role\"}","handlingStrategy":"validation","validationCode":"func hasRoleName(body []byte) bool {\n    var v struct{ Name string `json:\"name\"` }\n    _ = json.Unmarshal(body, &v)\n    return v.Name != \"\"\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use typed client structs for request bodies instead of maps","Generate clients from the OpenAPI spec"],"tags":["roles","rbac","request-validation"],"backgroundTag":"missing-required-request-field","analyzedSha":"5069bf80b08f1f00d7e014eccc09902f9871004f","analyzedAt":"2026-08-28T06:22:12.824Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}