{"record":{"id":"9bc72acf553f7043","repo":"SigNoz/signoz","slug":"invalid-alert-state","errorCode":null,"errorMessage":"invalid alert state","messagePattern":"invalid alert state","errorType":"validation","errorClass":null,"httpStatus":400,"severity":"error","filePath":"pkg/query-service/model/alerting.go","lineNumber":73,"sourceCode":"\t\tswitch value {\n\t\tcase \"inactive\":\n\t\t\t*s = StateInactive\n\t\tcase \"pending\":\n\t\t\t*s = StatePending\n\t\tcase \"firing\":\n\t\t\t*s = StateFiring\n\t\tcase \"nodata\":\n\t\t\t*s = StateNoData\n\t\tcase \"disabled\":\n\t\t\t*s = StateDisabled\n\t\tcase \"recovering\":\n\t\t\t*s = StateRecovering\n\t\tdefault:\n\t\t\t*s = StateInactive\n\t\t}\n\t\treturn nil\n\tdefault:\n\t\treturn errors.New(\"invalid alert state\")\n\t}\n}\n\nfunc (s *AlertState) Scan(value interface{}) error {\n\tv, ok := value.(string)\n\tif !ok {\n\t\treturn errors.New(\"invalid alert state\")\n\t}\n\tswitch v {\n\tcase \"inactive\":\n\t\t*s = StateInactive\n\tcase \"pending\":\n\t\t*s = StatePending\n\tcase \"firing\":\n\t\t*s = StateFiring\n\tcase \"nodata\":\n\t\t*s = StateNoData\n\tcase \"disabled\":","sourceCodeStart":55,"sourceCodeEnd":91,"githubUrl":"https://github.com/SigNoz/signoz/blob/5069bf80b08f1f00d7e014eccc09902f9871004f/pkg/query-service/model/alerting.go#L55-L91","documentation":"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'.","triggerScenarios":"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.","commonSituations":"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'.","solutions":["Send the state as one of the exact supported lowercase strings, e.g. \"inactive\", \"pending\", \"firing\", \"recovering\"","Ensure the JSON value is a string, not a number or nested object","Align UI/backend SigNoz versions if a newly introduced state string is being rejected"],"exampleFix":"// before\n{\"title\": \"high error rate\", \"state\": 2}\n// after\n{\"title\": \"high error rate\", \"state\": \"firing\"}","handlingStrategy":"type-guard","validationCode":"var validStates = map[string]bool{\"inactive\": true, \"pending\": true, \"firing\": true, \"recovering\": true}\nif !validStates[alert.State] {\n    return fmt.Errorf(\"unsupported alert state %q\", alert.State)\n}","typeGuard":"func isValidAlertState(s string) bool {\n    switch s {\n    case \"inactive\", \"pending\", \"firing\", \"recovering\":\n        return true\n    }\n    return false\n}","tryCatchPattern":"if err := json.Unmarshal(data, &alert); err != nil {\n    if strings.Contains(err.Error(), \"invalid alert state\") {\n        return fmt.Errorf(\"state must be one of inactive|pending|firing|recovering, got %s\", data)\n    }\n    return err\n}","preventionTips":["Keep UI and backend SigNoz versions in sync so state enums match","Send states as lowercase strings from a shared constant set","Never serialize enums as integers in alert payloads"],"tags":["validation","alerting","json-deserialization","sigpoz"],"backgroundTag":"invalid-enum-value-in-json","analyzedSha":"5069bf80b08f1f00d7e014eccc09902f9871004f","analyzedAt":"2026-08-28T06:22:12.824Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}