SigNoz/signoz · error

type and duration param cannot be empty from the query

Error message

type and duration param cannot be empty from the query

What it means

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.

Source

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

		return nil, fmt.Errorf("%s param is not in correct timestamp format", param)
	}

	timeFmt := time.Unix(0, timeUnix)

	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)

View on GitHub (pinned to 5069bf80b0)

Solutions

  1. Add both query params, e.g. ?type=traces&duration=72h
  2. Verify param names exactly match 'type' and 'duration' (case-sensitive keys)
  3. Check the SigNoz API docs / frontend network tab to confirm the expected retention API shape for your version

Example fix

// before
curl -X PUT 'http://localhost:8080/api/v1/ttl?duration=72h'
// after
curl -X PUT 'http://localhost:8080/api/v1/ttl?type=traces&duration=72h'
Defensive patterns

Strategy: validation

Validate before calling

t := r.URL.Query().Get("type"); d := r.URL.Query().Get("duration")
if t == "" || d == "" { return errors.New("type and duration query params are required") }

Try / catch

Check HTTP 400 response body and surface the message to the caller with the missing param name.

Prevention

When it happens

Trigger: 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.

Common situations: 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'.

Related errors


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