SigNoz/signoz · error

invalid data type for resource attribute: %s

Error message

invalid data type for resource attribute: %s

What it means

buildResourceFiltersFromFilterItems rejects a resource filter whose key DataType is not string unless the operator is IN or NOT_IN. Resource attribute filter values are expected to be strings (or lists for IN/NOT IN), so numeric/bool typed keys fail this validation.

Source

Thrown at pkg/query-service/app/resource/resource_query_builder.go:228

	if fs == nil || len(fs.Items) == 0 {
		return nil, nil
	}
	for _, item := range fs.Items {
		// skip anything other than resource attribute
		if item.Key.Type != v3.AttributeKeyTypeResource {
			continue
		}

		// since out map is in lower case we are converting it to lowercase
		operatorLower := strings.ToLower(string(item.Operator))
		op := v3.FilterOperator(operatorLower)
		keyName := item.Key.Key

		// resource filter value data type will always be string
		// will be an interface if the operator is IN or NOT IN
		if item.Key.DataType != v3.AttributeKeyDataTypeString &&
			(op != v3.FilterOperatorIn && op != v3.FilterOperatorNotIn) {
			return nil, fmt.Errorf("invalid data type for resource attribute: %s", item.Key.Key)
		}

		var value interface{}
		var err error
		if op != v3.FilterOperatorExists && op != v3.FilterOperatorNotExists {
			// make sure to cast the value regardless of the actual type
			value, err = utils.ValidateAndCastValue(item.Value, item.Key.DataType)
			if err != nil {
				return nil, fmt.Errorf("failed to validate and cast value for %s: %v", item.Key.Key, err)
			}
		}

		if logsOp, ok := resourceLogOperators[op]; ok {
			members := []string{keyName}
			if resolveSemconvFamilies {
				members = semconv.Members(semconv.KindAttribute, telemetrytypes.FieldKeySelector{
					Name:         keyName,
					Signal:       telemetrytypes.SignalTraces,

View on GitHub (pinned to 5069bf80b0)

Solutions

  1. Use the in (IN) or not in (NOT IN) operator if you must filter a non-string resource attribute
  2. Change the key's DataType to string in the filter item before sending
  3. Filter on the corresponding body/severity field instead if it is not a resource attribute

Example fix

// before
item.Key.DataType = v3.AttributeKeyDataTypeFloat64
item.Operator = v3.FilterOperatorEqual

// after
item.Operator = v3.FilterOperatorIn // IN/NOT_IN are allowed for non-string types
Defensive patterns

Strategy: validation

Validate before calling

op := item.Operator
if item.Key.DataType != v3.AttributeKeyDataTypeString && op != v3.FilterOperatorIn && op != v3.FilterOperatorNotIn {
    return fmt.Errorf("key %s must be string-typed or use in/not-in", item.Key.Key)
}

Type guard

func isStringOrListOp(dt v3.AttributeKeyDataType, op v3.FilterOperator) bool {
    return dt == v3.AttributeKeyDataTypeString || op == v3.FilterOperatorIn || op == v3.FilterOperatorNotIn
}

Prevention

When it happens

Trigger: Applying a resource filter on a log query where the attribute key has DataType like float64/int64/bool and the operator is =, !=, contains, etc. (not in/not nin).

Common situations: Selecting a numerically-typed resource attribute in the logs explorer filter bar with an equality operator; programmatic filter sets built from saved views that stored a non-string data type for the key.

Related errors


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