thanos-io/thanos · error
empty alertState
Error message
empty alertState
What it means
Raised in AlertState.UnmarshalJSON as a guard: the unquoted alert-state string is empty, meaning the JSON payload contained "" (or an escaped empty string) for the rule state, which maps to no valid AlertState value.
Solutions
- Provide a non-empty state string such as "firing", "pending", or "inactive"
- Fix the producer that emits empty state fields
- Add client-side validation to reject empty state before decoding
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at pkg/rules/rulespb/custom.go:279 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of thanos-io/thanos@35b8b99117 (2026-09-07).
Data as JSON: /api/errors/94eb0468b2abcd06.
Report an issue: GitHub.
Appendix: source
Thrown at pkg/rules/rulespb/custom.go:279
}
func (r *RuleGroup) MarshalJSON() ([]byte, error) {
if r.Rules == nil {
// Ensure that empty slices are marshaled as '[]' and not 'null'.
r.Rules = make([]*Rule, 0)
}
type plain RuleGroup
return json.Marshal((*plain)(r))
}
func (x *AlertState) UnmarshalJSON(entry []byte) error {
fieldStr, err := strconv.Unquote(string(entry))
if err != nil {
return errors.Wrapf(err, "alertState: unquote %v", string(entry))
}
if fieldStr == "" {
return errors.New("empty alertState")
}
state, ok := AlertState_value[strings.ToUpper(fieldStr)]
if !ok {
return errors.Errorf("unknown alertState: %v", string(entry))
}
*x = AlertState(state)
return nil
}
func (x *AlertState) MarshalJSON() ([]byte, error) {
return []byte(strconv.Quote(strings.ToLower(x.String()))), nil
}
// Compare compares alert state x and y and returns:
//
// < 0 if x < y (alert state x is more critical than alert state y)
// 0 if x == yView on GitHub (pinned to 35b8b99117)