SigNoz/signoz · error · errors SigNozError

ErrCodeRoleInvalidInput

ErrCodeRoleInvalidInput

Error message

name is missing from the request

What it means

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.

Source

Thrown at pkg/types/authtypes/role.go:178

		return errors.Newf(errors.TypeInvalidInput, ErrCodeRoleInvalidInput, "cannot edit/delete managed role: %s", role.Name)
	}

	return nil
}

func (role *PostableRole) UnmarshalJSON(data []byte) error {
	shadow := struct {
		Name              string           `json:"name"`
		Description       string           `json:"description"`
		TransactionGroups *json.RawMessage `json:"transactionGroups"`
	}{}

	if err := json.Unmarshal(data, &shadow); err != nil {
		return err
	}

	if shadow.Name == "" {
		return errors.New(errors.TypeInvalidInput, ErrCodeRoleInvalidInput, "name is missing from the request")
	}

	if match := roleNameRegex.MatchString(shadow.Name); !match {
		return errors.New(errors.TypeInvalidInput, ErrCodeRoleInvalidInput, "name must contain only lowercase letters (a-z) and hyphens (-), and be at most 50 characters long.")
	}

	if strings.HasPrefix(shadow.Name, managedRolePrefix) {
		return errors.Newf(errors.TypeInvalidInput, ErrCodeRoleInvalidInput, "role name cannot start with %q as it is reserved for SigNoz managed roles.", managedRolePrefix)
	}

	var transactionGroups TransactionGroups
	if shadow.TransactionGroups != nil {
		var err error
		transactionGroups, err = NewTransactionGroups(*shadow.TransactionGroups)
		if err != nil {
			return err
		}
	}

View on GitHub (pinned to 5069bf80b0)

Solutions

  1. Include a non-empty "name" field in the create-role request body
  2. Check casing: the field is lowercase "name" per the JSON tag
  3. Use the PATCH/update endpoint when you only want to change other fields

Example fix

// before
{"description": "view-only role"}
// after
{"name": "view-only", "description": "view-only role"}
Defensive patterns

Strategy: validation

Validate before calling

func hasRoleName(body []byte) bool {
    var v struct{ Name string `json:"name"` }
    _ = json.Unmarshal(body, &v)
    return v.Name != ""
}

Prevention

When it happens

Trigger: POST /api/v1/roles (or equivalent) with a JSON body lacking "name" or with "name": "".

Common situations: Client sends a partial update payload to the create endpoint, or a typo like "Name" instead of "name" (JSON tags are lowercase).

Related errors


AI-assisted analysis of SigNoz/signoz@5069bf80b0 (2026-08-28). Data as JSON: /api/errors/4ccc51ea854b35cb. Report an issue: GitHub.