{"record":{"id":"b4db580312a86cd2","repo":"SigNoz/signoz","slug":"order-must-be-asc-or-desc","errorCode":null,"errorMessage":"order must be asc or desc","messagePattern":"order must be asc or desc","errorType":"validation","errorClass":null,"httpStatus":400,"severity":"error","filePath":"pkg/query-service/model/alerting.go","lineNumber":167,"sourceCode":"type 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\ntype RuleStateTransition struct {\n\tRuleID         string     `json:\"ruleID\" ch:\"rule_id\"`\n\tState          AlertState `json:\"state\" ch:\"state\"`\n\tFiringTime     int64      `json:\"firingTime\" ch:\"firing_time\"`\n\tResolutionTime int64      `json:\"resolutionTime\" ch:\"resolution_time\"`\n}","sourceCodeStart":149,"sourceCodeEnd":185,"githubUrl":"https://github.com/SigNoz/signoz/blob/5069bf80b08f1f00d7e014eccc09902f9871004f/pkg/query-service/model/alerting.go#L149-L185","documentation":"QueryRuleStateHistory.Validate restricts the Order param for rule state history to exactly 'asc' or 'desc'; any other value (including empty, uppercase, or 'ascending') is rejected.","triggerScenarios":"Sending order=ASC, order=ascending, or omitting order entirely while calling getRuleStateHistory.","commonSituations":"Clients defaulting to verbose direction names; case-sensitive strings from user input; missing param because the developer assumed a server-side default.","solutions":["Send order=asc or order=desc exactly (lowercase)","Default to 'desc' client-side when the user hasn't chosen","Lowercase and trim user input before sending"],"exampleFix":"// before\nGET /api/rules/<id>/state_history?order=ASC&start=..&end=..\n\n// after\nGET /api/rules/<id>/state_history?order=asc&start=..&end=..","handlingStrategy":"validation","validationCode":"if r.Order != \"asc\" && r.Order != \"desc\" {\n    r.Order = \"desc\"\n}","typeGuard":"func isValidOrder(s string) bool { return s == \"asc\" || s == \"desc\" }","tryCatchPattern":null,"preventionTips":["Default order to 'desc' when unset","Normalize case before sending"],"tags":["signoz","alerting","validation","query-params"],"backgroundTag":"invalid-query-parameter","analyzedSha":"5069bf80b08f1f00d7e014eccc09902f9871004f","analyzedAt":"2026-08-28T06:22:12.824Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}