{"record":{"id":"7772fe05f417dcf9","repo":"SigNoz/signoz","slug":"start-and-end-are-required","errorCode":null,"errorMessage":"start and end are required","messagePattern":"start and end are required","errorType":"validation","errorClass":null,"httpStatus":400,"severity":"error","filePath":"pkg/query-service/model/alerting.go","lineNumber":161,"sourceCode":"\tValue        float64      `json:\"value\" ch:\"value\"`\n\n\tRelatedTracesLink string `json:\"relatedTracesLink\"`\n\tRelatedLogsLink   string `json:\"relatedLogsLink\"`\n}\n\ntype QueryRuleStateHistory struct {\n\tStart   int64         `json:\"start\"`\n\tEnd     int64         `json:\"end\"`\n\tState   string        `json:\"state\"`\n\tFilters *v3.FilterSet `json:\"filters\"`\n\tOffset  int64         `json:\"offset\"`\n\tLimit   int64         `json:\"limit\"`\n\tOrder   string        `json:\"order\"`\n}\n\nfunc (r *QueryRuleStateHistory) Validate() error {\n\tif r.Start == 0 || r.End == 0 {\n\t\treturn fmt.Errorf(\"start and end are required\")\n\t}\n\tif r.Offset < 0 || r.Limit < 0 {\n\t\treturn fmt.Errorf(\"offset and limit must be greater than 0\")\n\t}\n\tif r.Order != \"asc\" && r.Order != \"desc\" {\n\t\treturn fmt.Errorf(\"order must be asc or desc\")\n\t}\n\treturn nil\n}\n\ntype RuleStateHistoryContributor struct {\n\tFingerprint       uint64       `json:\"fingerprint\" ch:\"fingerprint\"`\n\tLabels            LabelsString `json:\"labels\" ch:\"labels\"`\n\tCount             uint64       `json:\"count\" ch:\"count\"`\n\tRelatedTracesLink string       `json:\"relatedTracesLink\"`\n\tRelatedLogsLink   string       `json:\"relatedLogsLink\"`\n}\n","sourceCodeStart":143,"sourceCodeEnd":179,"githubUrl":"https://github.com/SigNoz/signoz/blob/5069bf80b08f1f00d7e014eccc09902f9871004f/pkg/query-service/model/alerting.go#L143-L179","documentation":"QueryRuleStateHistory.Validate requires both Start and End (epoch values) for alerting rule state history queries; a zero value for either means the time range is missing and the query is rejected before hitting ClickHouse.","triggerScenarios":"Calling the rule state history API (via getRuleStateHistory) without start/end query params, or with one of them set to 0.","commonSituations":"Frontend builds the history URL but omits the time-range params; scripts calling the endpoint directly with only limit/order; defaults of 0 from uninitialized structs.","solutions":["Provide both start and end as non-zero epoch millisecond values","Default to the last N hours client-side if the user opened the panel without a range","Validate params before making the request"],"exampleFix":"// before\nGET /api/rules/<id>/state_history?limit=10\n\n// after\nGET /api/rules/<id>/state_history?start=1700000000000&end=1700086400000&limit=10","handlingStrategy":"validation","validationCode":"if r.Start == 0 || r.End == 0 {\n    r.Start = time.Now().Add(-6 * time.Hour).UnixMilli()\n    r.End = time.Now().UnixMilli()\n}","typeGuard":"func hasTimeRange(r model.QueryRuleStateHistory) bool { return r.Start != 0 && r.End != 0 }","tryCatchPattern":null,"preventionTips":["Always attach the active time range to history requests","Unit-test param serialization for history endpoints"],"tags":["signoz","alerting","validation","query-params"],"backgroundTag":"missing-required-parameter","analyzedSha":"5069bf80b08f1f00d7e014eccc09902f9871004f","analyzedAt":"2026-08-28T06:22:12.824Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}