SigNoz/signoz · error

CODE_INVALID_INPUT

CODE_INVALID_INPUT

Error message

invalid filter JSON

What it means

NewStorableQuickFilter validates and stores a quick filter: it checks the signal value and then json.Unmarshals the filterJSON bytes into []v3.AttributeKey. If the JSON is malformed or its elements don't match the AttributeKey schema, it returns CODE_INVALID_INPUT 'invalid filter JSON'.

Source

Thrown at pkg/types/quickfiltertypes/filter.go:94

type UpdatableQuickFilters struct {
	Signal  Signal            `json:"signal"`
	Filters []v3.AttributeKey `json:"filters"`
}

// NewStorableQuickFilter creates a new StorableQuickFilter after validation.
func NewStorableQuickFilter(orgID valuer.UUID, signal Signal, filterJSON []byte) (*StorableQuickFilter, error) {
	if orgID.StringValue() == "" {
		return nil, errors.Newf(errors.TypeInvalidInput, errors.CodeInvalidInput, "orgID is required")
	}

	if _, err := NewSignal(signal.StringValue()); err != nil {
		return nil, err
	}

	var filters []v3.AttributeKey
	if err := json.Unmarshal(filterJSON, &filters); err != nil {
		return nil, errors.Wrapf(err, errors.TypeInvalidInput, errors.CodeInvalidInput, "invalid filter JSON")
	}

	now := time.Now()
	return &StorableQuickFilter{
		Identifiable: types.Identifiable{
			ID: valuer.GenerateUUID(),
		},
		OrgID:  orgID,
		Signal: signal,
		Filter: string(filterJSON),
		TimeAuditable: types.TimeAuditable{
			CreatedAt: now,
			UpdatedAt: now,
		},
	}, nil
}

// Update updates an existing StorableQuickFilter with new filter data after validation.

View on GitHub (pinned to 5069bf80b0)

Solutions

  1. Ensure the body is a JSON array of AttributeKey objects: [{"key":"service.name","dataType":"string",...}]
  2. Validate client-side with the same struct before sending
  3. Check gateway/proxy request-size limits if large filters get truncated

Example fix

// before
filterJSON := []byte(`{"key":"service.name","dataType":"string"}`)

// after
filterJSON := []byte(`[{"key":"service.name","dataType":"string","isColumn":true}]`)
Defensive patterns

Strategy: validation

Validate before calling

var attrs []v3.AttributeKey
if err := json.Unmarshal(filterJSON, &attrs); err != nil || len(attrs) == 0 {
    return errors.New("filters must be a non-empty JSON array of AttributeKey")
}

Type guard

func isValidFilterJSON(b []byte) bool {
    var attrs []v3.AttributeKey
    return json.Unmarshal(b, &attrs) == nil
}

Prevention

When it happens

Trigger: POST/PUT to the quick-filters API (UpdateQuickFilters) where the filter payload is invalid JSON, a JSON object instead of an array, or array elements missing/wrong-typed fields for v3.AttributeKey (key, dataType, isColumn...).

Common situations: Frontend sending the filter object directly instead of wrapping it in an array; truncation of large filter payloads by proxies; mismatched AttributeKey field names after a v3 API schema change.

Related errors


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