{"record":{"id":"3471e50c2e1c9b24","repo":"SigNoz/signoz","slug":"type-param-should-be-metrics-traces-logs-got-v","errorCode":null,"errorMessage":"type param should be metrics|traces|logs, got %v","messagePattern":"type param should be metrics\\|traces\\|logs, got (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/query-service/app/parser.go","lineNumber":437,"sourceCode":"\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)\n\t\tif err != nil || toColdParsed.Seconds() <= 0 {\n\t\t\treturn nil, fmt.Errorf(\"not a valid toCold TTL duration %v\", toColdDuration)\n\t\t}\n\t\tif toColdParsed.Seconds() != 0 && toColdParsed.Seconds() >= durationParsed.Seconds() {\n\t\t\treturn nil, fmt.Errorf(\"delete TTL should be greater than cold storage move TTL\")","sourceCodeStart":419,"sourceCodeEnd":455,"githubUrl":"https://github.com/SigNoz/signoz/blob/5069bf80b08f1f00d7e014eccc09902f9871004f/pkg/query-service/app/parser.go#L419-L455","documentation":"parseTTLParams validates that the 'type' query parameter is one of the supported retention types: 'traces', 'metrics', or 'logs' (compared against retentiontypes.TraceTTL/MetricsTTL/LogsTTL constants). Any other value is rejected with the offending value echoed back.","triggerScenarios":"Passing ?type=trace (singular), ?type=spans, ?type=logs2, or any unrecognized string to the setTTL endpoint.","commonSituations":"Singular vs plural confusion ('trace' instead of 'traces'); assuming arbitrary signal names are accepted; older SigNoz versions that only supported a subset of types.","solutions":["Use exactly one of: traces, metrics, logs","Check for trailing whitespace or URL-encoding issues in the type value","Upgrade if running an old version where logs/metrics TTL was not yet supported"],"exampleFix":"// before\n?type=trace&duration=72h\n// after\n?type=traces&duration=72h","handlingStrategy":"validation","validationCode":"var validTypes = map[string]bool{\"traces\":true,\"metrics\":true,\"logs\":true}\nif !validTypes[r.URL.Query().Get(\"type\")] { return fmt.Errorf(\"unsupported type %q\", t) }","typeGuard":"func isValidTTLType(t string) bool { return t==\"traces\"||t==\"metrics\"||t==\"logs\" }","tryCatchPattern":null,"preventionTips":["Centralize the allowed type list as a constant shared by client and server","Add unit tests asserting enum values before release"],"tags":["signoz","retention","ttl","enum-validation"],"backgroundTag":"invalid-enum-parameter","analyzedSha":"5069bf80b08f1f00d7e014eccc09902f9871004f","analyzedAt":"2026-08-28T06:22:12.824Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}