SigNoz/signoz · error · errors SigNozError
ErrCodeUserRoleInvalidInput
ErrCodeUserRoleInvalidInput
Error message
userId is required
What it means
PostableUserRole.UnmarshalJSON requires a non-zero userId. The alias struct decodes UserID as a typed ID; a zero value (missing, empty, or all-zero UUID) fails validation before roleId is checked.
Source
Thrown at pkg/types/authtypes/user_role.go:63
type DeprecatedPostableUserRole struct {
ID valuer.UUID `json:"id" required:"true"`
}
type PostableUserRole struct {
UserID valuer.UUID `json:"userId" required:"true"`
RoleID valuer.UUID `json:"roleId" required:"true"`
}
func (p *PostableUserRole) UnmarshalJSON(data []byte) error {
type Alias PostableUserRole
var temp Alias
if err := json.Unmarshal(data, &temp); err != nil {
return err
}
if temp.UserID.IsZero() {
return errors.New(errors.TypeInvalidInput, ErrCodeUserRoleInvalidInput, "userId is required")
}
if temp.RoleID.IsZero() {
return errors.New(errors.TypeInvalidInput, ErrCodeUserRoleInvalidInput, "roleId is required")
}
*p = PostableUserRole(temp)
return nil
}
func (p *PostableUser) UnmarshalJSON(data []byte) error {
type Alias PostableUser
var temp Alias
if err := json.Unmarshal(data, &temp); err != nil {
return err
}
View on GitHub (pinned to 5069bf80b0)
Solutions
- Include a valid non-zero userId in the request body
- Check the field name casing matches the JSON tag (userId) exactly
- Log the decoded payload before send to confirm the field is serialized
- Validate required fields client-side before submitting
Example fix
// before
{"roleId":"01HQ..."}
// after
{"userId":"01HQ...user","roleId":"01HQ...role"}
Defensive patterns
Strategy: validation
Validate before calling
if req.UserID == "" || isZeroUUID(req.UserID) { return errors.New("userId required") } Type guard
func hasUserID(p map[string]any) bool { id, ok := p["userId"].(string); return ok && id != "" && id != "00000000-0000-0000-0000-000000000000" } Prevention
- Validate required IDs before POST
- Use typed client SDKs so missing fields are compile-time visible
When it happens
Trigger: POSTing a user-role assignment JSON without userId, with an empty string, or with an all-zero UUID; unmarshalling request bodies in role-assignment APIs.
Common situations: Clients constructing payloads programmatically omitting optional-looking fields; frontend forms not validating the user selector; test fixtures copied without user IDs.
Related errors
- ErrCodeRoleInvalidInput
- invalid_input
- CodeInvalidInput
- ErrCodeRoleInvalidInput
- ErrCodeInvalidGatewayConfig
AI-assisted analysis of SigNoz/signoz@5069bf80b0 (2026-08-28).
Data as JSON: /api/errors/2cb87322f2105a99.
Report an issue: GitHub.