SigNoz/signoz · error

invalid alert state

Error message

invalid alert state

What it means

AlertState.UnmarshalJSON accepts state only from a string JSON token and only among the known alert states (inactive/pending/firing/recovering etc.); anything else — a number, object, or unrecognized string — yields 'invalid alert state'.

Source

Thrown at pkg/query-service/model/alerting.go:73

		switch value {
		case "inactive":
			*s = StateInactive
		case "pending":
			*s = StatePending
		case "firing":
			*s = StateFiring
		case "nodata":
			*s = StateNoData
		case "disabled":
			*s = StateDisabled
		case "recovering":
			*s = StateRecovering
		default:
			*s = StateInactive
		}
		return nil
	default:
		return errors.New("invalid alert state")
	}
}

func (s *AlertState) Scan(value interface{}) error {
	v, ok := value.(string)
	if !ok {
		return errors.New("invalid alert state")
	}
	switch v {
	case "inactive":
		*s = StateInactive
	case "pending":
		*s = StatePending
	case "firing":
		*s = StateFiring
	case "nodata":
		*s = StateNoData
	case "disabled":

View on GitHub (pinned to 5069bf80b0)

Solutions

  1. Send the state as one of the exact supported lowercase strings, e.g. "inactive", "pending", "firing", "recovering"
  2. Ensure the JSON value is a string, not a number or nested object
  3. Align UI/backend SigNoz versions if a newly introduced state string is being rejected

Example fix

// before
{"title": "high error rate", "state": 2}
// after
{"title": "high error rate", "state": "firing"}
Defensive patterns

Strategy: type-guard

Validate before calling

var validStates = map[string]bool{"inactive": true, "pending": true, "firing": true, "recovering": true}
if !validStates[alert.State] {
    return fmt.Errorf("unsupported alert state %q", alert.State)
}

Type guard

func isValidAlertState(s string) bool {
    switch s {
    case "inactive", "pending", "firing", "recovering":
        return true
    }
    return false
}

Try / catch

if err := json.Unmarshal(data, &alert); err != nil {
    if strings.Contains(err.Error(), "invalid alert state") {
        return fmt.Errorf("state must be one of inactive|pending|firing|recovering, got %s", data)
    }
    return err
}

Prevention

When it happens

Trigger: POST/PUT to the alert API with "state": 1, "state": "paused", "state": {"value":"firing"}, or null; or a rule YAML/front-end payload sending a state name added in a newer SigNoz version to an older backend.

Common situations: Version mismatch where the UI emits a new state string the backend does not know; API consumers storing state as an enum integer; hand-written rule payloads with typos like 'Firing' (case-sensitive) or 'active'.

Related errors


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