SigNoz/signoz · error

type param should be metrics|traces|logs, got %v

Error message

type param should be metrics|traces|logs, got %v

What it means

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.

Source

Thrown at pkg/query-service/app/parser.go:437

	return &timeFmt, nil

}

func parseTTLParams(r *http.Request) (*retentiontypes.TTLParams, error) {

	// make sure either of the query params are present
	typeTTL := r.URL.Query().Get("type")
	delDuration := r.URL.Query().Get("duration")
	coldStorage := r.URL.Query().Get("coldStorage")
	toColdDuration := r.URL.Query().Get("toColdDuration")

	if len(typeTTL) == 0 || len(delDuration) == 0 {
		return nil, fmt.Errorf("type and duration param cannot be empty from the query")
	}

	// Validate the type parameter
	if typeTTL != retentiontypes.TraceTTL && typeTTL != retentiontypes.MetricsTTL && typeTTL != retentiontypes.LogsTTL {
		return nil, fmt.Errorf("type param should be metrics|traces|logs, got %v", typeTTL)
	}

	// Validate the TTL duration.
	durationParsed, err := time.ParseDuration(delDuration)
	if err != nil || durationParsed.Seconds() <= 0 {
		return nil, fmt.Errorf("not a valid TTL duration %v", delDuration)
	}

	var toColdParsed time.Duration

	// If some cold storage is provided, validate the cold storage move TTL.
	if len(coldStorage) > 0 {
		toColdParsed, err = time.ParseDuration(toColdDuration)
		if err != nil || toColdParsed.Seconds() <= 0 {
			return nil, fmt.Errorf("not a valid toCold TTL duration %v", toColdDuration)
		}
		if toColdParsed.Seconds() != 0 && toColdParsed.Seconds() >= durationParsed.Seconds() {
			return nil, fmt.Errorf("delete TTL should be greater than cold storage move TTL")

View on GitHub (pinned to 5069bf80b0)

Solutions

  1. Use exactly one of: traces, metrics, logs
  2. Check for trailing whitespace or URL-encoding issues in the type value
  3. Upgrade if running an old version where logs/metrics TTL was not yet supported

Example fix

// before
?type=trace&duration=72h
// after
?type=traces&duration=72h
Defensive patterns

Strategy: validation

Validate before calling

var validTypes = map[string]bool{"traces":true,"metrics":true,"logs":true}
if !validTypes[r.URL.Query().Get("type")] { return fmt.Errorf("unsupported type %q", t) }

Type guard

func isValidTTLType(t string) bool { return t=="traces"||t=="metrics"||t=="logs" }

Prevention

When it happens

Trigger: Passing ?type=trace (singular), ?type=spans, ?type=logs2, or any unrecognized string to the setTTL endpoint.

Common situations: Singular vs plural confusion ('trace' instead of 'traces'); assuming arbitrary signal names are accepted; older SigNoz versions that only supported a subset of types.

Related errors


AI-assisted analysis of SigNoz/signoz@5069bf80b0 (2026-08-28). Data as JSON: /api/errors/3471e50c2e1c9b24. Report an issue: GitHub.