{"record":{"id":"9acb3ba54db5da15","repo":"SigNoz/signoz","slug":"type-and-duration-param-cannot-be-empty-from-the-q","errorCode":null,"errorMessage":"type and duration param cannot be empty from the query","messagePattern":"type and duration param cannot be empty from the query","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/query-service/app/parser.go","lineNumber":432,"sourceCode":"\t\treturn nil, fmt.Errorf(\"%s param is not in correct timestamp format\", param)\n\t}\n\n\ttimeFmt := time.Unix(0, timeUnix)\n\n\treturn &timeFmt, nil\n\n}\n\nfunc parseTTLParams(r *http.Request) (*retentiontypes.TTLParams, error) {\n\n\t// make sure either of the query params are present\n\ttypeTTL := r.URL.Query().Get(\"type\")\n\tdelDuration := r.URL.Query().Get(\"duration\")\n\tcoldStorage := r.URL.Query().Get(\"coldStorage\")\n\ttoColdDuration := r.URL.Query().Get(\"toColdDuration\")\n\n\tif len(typeTTL) == 0 || len(delDuration) == 0 {\n\t\treturn nil, fmt.Errorf(\"type and duration param cannot be empty from the query\")\n\t}\n\n\t// Validate the type parameter\n\tif typeTTL != retentiontypes.TraceTTL && typeTTL != retentiontypes.MetricsTTL && typeTTL != retentiontypes.LogsTTL {\n\t\treturn nil, fmt.Errorf(\"type param should be metrics|traces|logs, got %v\", typeTTL)\n\t}\n\n\t// Validate the TTL duration.\n\tdurationParsed, err := time.ParseDuration(delDuration)\n\tif err != nil || durationParsed.Seconds() <= 0 {\n\t\treturn nil, fmt.Errorf(\"not a valid TTL duration %v\", delDuration)\n\t}\n\n\tvar toColdParsed time.Duration\n\n\t// If some cold storage is provided, validate the cold storage move TTL.\n\tif len(coldStorage) > 0 {\n\t\ttoColdParsed, err = time.ParseDuration(toColdDuration)","sourceCodeStart":414,"sourceCodeEnd":450,"githubUrl":"https://github.com/SigNoz/signoz/blob/5069bf80b08f1f00d7e014eccc09902f9871004f/pkg/query-service/app/parser.go#L414-L450","documentation":"Thrown by parseTTLParams when setting TTL via the retention API. The request must include both a 'type' and a 'duration' query parameter; if either is missing or empty, this error is returned before any validation occurs. It is a 400-class user-input error from the SigNoz query-service.","triggerScenarios":"Calling the TTL endpoint (e.g. PUT /api/v1/retention or /api/v1/ttl) without ?type=traces or without ?duration=... in the URL query string.","commonSituations":"Client scripts or automation that set retention but only pass duration; typos in param names (e.g. 'ttl' instead of 'duration'); UI version mismatch where the frontend stops sending 'type'.","solutions":["Add both query params, e.g. ?type=traces&duration=72h","Verify param names exactly match 'type' and 'duration' (case-sensitive keys)","Check the SigNoz API docs / frontend network tab to confirm the expected retention API shape for your version"],"exampleFix":"// before\ncurl -X PUT 'http://localhost:8080/api/v1/ttl?duration=72h'\n// after\ncurl -X PUT 'http://localhost:8080/api/v1/ttl?type=traces&duration=72h'","handlingStrategy":"validation","validationCode":"t := r.URL.Query().Get(\"type\"); d := r.URL.Query().Get(\"duration\")\nif t == \"\" || d == \"\" { return errors.New(\"type and duration query params are required\") }","typeGuard":null,"tryCatchPattern":"Check HTTP 400 response body and surface the message to the caller with the missing param name.","preventionTips":["Always construct retention URLs with both type and duration","Wrap TTL calls in a small client function that enforces required params"],"tags":["signoz","retention","ttl","query-params","bad-request"],"backgroundTag":"missing-query-parameter","analyzedSha":"5069bf80b08f1f00d7e014eccc09902f9871004f","analyzedAt":"2026-08-28T06:22:12.824Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}