SigNoz/signoz · error · errors.SignozError

ErrCodeRoleInvalidInput

ErrCodeRoleInvalidInput

Error message

id is missing from the request

What it means

Returned by the SignOz role API handlers when the request path lacks the {id} variable (mux.Vars(r)["id"] missing). It indicates a routing problem: the request reached the handler through a route that doesn't declare :id, or the mux wasn't configured with the expected route pattern.

Source

Thrown at pkg/authz/signozauthzapi/handler.go:59

	if err != nil {
		render.Error(rw, err)
		return
	}

	render.Success(rw, http.StatusCreated, types.Identifiable{ID: role.ID})
}

func (handler *handler) Get(rw http.ResponseWriter, r *http.Request) {
	ctx := r.Context()
	claims, err := authtypes.ClaimsFromContext(ctx)
	if err != nil {
		render.Error(rw, err)
		return
	}

	id, ok := mux.Vars(r)["id"]
	if !ok {
		render.Error(rw, errors.New(errors.TypeInvalidInput, authtypes.ErrCodeRoleInvalidInput, "id is missing from the request"))
		return
	}
	roleID, err := valuer.NewUUID(id)
	if err != nil {
		render.Error(rw, err)
		return
	}

	role, err := handler.authz.Get(ctx, valuer.MustNewUUID(claims.OrgID), roleID)
	if err != nil {
		render.Error(rw, err)
		return
	}

	render.Success(rw, http.StatusOK, role)
}

func (handler *handler) List(rw http.ResponseWriter, r *http.Request) {

View on GitHub (pinned to 5069bf80b0)

Solutions

  1. Register the route with the id pattern: r.HandleFunc("/api/v1/roles/{id}", ...) and include the id in the request URL
  2. If behind a proxy, verify the full path (including the UUID segment) is forwarded
  3. In tests, use mux.SetURLVars(r, map[string]string{"id": "..."}) to populate vars

Example fix

// before
router.HandleFunc("/api/v1/roles", h.Get)

// after
router.HandleFunc("/api/v1/roles/{id}", h.Get)
Defensive patterns

Strategy: validation

Validate before calling

vars := mux.Vars(r)
id, ok := vars["id"]
if !ok || id == "" {
    http.Error(rw, "id path parameter required", http.StatusBadRequest)
    return
}

Prevention

When it happens

Trigger: Calling GET/PUT on a route registered without the /{id} path parameter, or hitting the handler with a URL where the id segment is absent so mux doesn't populate Vars.

Common situations: Custom router wiring that registers /roles instead of /roles/{id}; proxy/gateway stripping the trailing path segment; tests invoking the handler directly without going through the mux route.

Related errors


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