SigNoz/signoz · error
start and end are required
Error message
start and end are required
What it means
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.
Source
Thrown at pkg/query-service/model/alerting.go:161
Value float64 `json:"value" ch:"value"`
RelatedTracesLink string `json:"relatedTracesLink"`
RelatedLogsLink string `json:"relatedLogsLink"`
}
type QueryRuleStateHistory struct {
Start int64 `json:"start"`
End int64 `json:"end"`
State string `json:"state"`
Filters *v3.FilterSet `json:"filters"`
Offset int64 `json:"offset"`
Limit int64 `json:"limit"`
Order string `json:"order"`
}
func (r *QueryRuleStateHistory) Validate() error {
if r.Start == 0 || r.End == 0 {
return fmt.Errorf("start and end are required")
}
if r.Offset < 0 || r.Limit < 0 {
return fmt.Errorf("offset and limit must be greater than 0")
}
if r.Order != "asc" && r.Order != "desc" {
return fmt.Errorf("order must be asc or desc")
}
return nil
}
type RuleStateHistoryContributor struct {
Fingerprint uint64 `json:"fingerprint" ch:"fingerprint"`
Labels LabelsString `json:"labels" ch:"labels"`
Count uint64 `json:"count" ch:"count"`
RelatedTracesLink string `json:"relatedTracesLink"`
RelatedLogsLink string `json:"relatedLogsLink"`
}
View on GitHub (pinned to 5069bf80b0)
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
Example fix
// before GET /api/rules/<id>/state_history?limit=10 // after GET /api/rules/<id>/state_history?start=1700000000000&end=1700086400000&limit=10
Defensive patterns
Strategy: validation
Validate before calling
if r.Start == 0 || r.End == 0 {
r.Start = time.Now().Add(-6 * time.Hour).UnixMilli()
r.End = time.Now().UnixMilli()
} Type guard
func hasTimeRange(r model.QueryRuleStateHistory) bool { return r.Start != 0 && r.End != 0 } Prevention
- Always attach the active time range to history requests
- Unit-test param serialization for history endpoints
When it happens
Trigger: Calling the rule state history API (via getRuleStateHistory) without start/end query params, or with one of them set to 0.
Common situations: 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.
Understand the failure class
Background: Missing required parameter errors: what 'X is required' and 'the required X param is missing' mean, and how to fix them — this error's family across 27 libraries.
Related errors
- order must be asc or desc
- offset and limit must be greater than 0
- CodeLicenseUnavailable
- CodeLicenseUnavailable
- CodeInvalidInput
AI-assisted analysis of SigNoz/signoz@5069bf80b0 (2026-08-28).
Data as JSON: /api/errors/7772fe05f417dcf9.
Report an issue: GitHub.