weaviate/weaviate · error

path parameter cannot be empty

Error message

path parameter cannot be empty

What it means

Per-clause guard in validateSortClause: a sort element's path array has length zero (the switch on len(path) hits case 0). The order may already have been validated; the failure is wrapped as 'sort parameter at position N' by the caller, so the offending clause is identifiable.

Source

Thrown at entities/filters/sort_validator.go:52

	if len(errs) > 0 {
		return mergeErrs(errs)
	} else {
		return nil
	}
}

func validateSortClause(getClass func(string) *models.Class, className schema.ClassName, sort Sort) error {
	// validate current
	path, order := sort.Path, sort.Order

	if len(order) > 0 && order != "asc" && order != "desc" {
		return errors.Errorf(`invalid order parameter, `+
			`possible values are: ["asc", "desc"] not: "%s"`, order)
	}

	switch len(path) {
	case 0:
		return errors.New("path parameter cannot be empty")
	case 1:
		class := getClass(className.String())
		if class == nil {
			return errors.Errorf("class %q does not exist in schema", className)
		}
		propName := schema.PropertyName(path[0])
		if IsInternalProperty(propName) {
			// handle internal properties
			return nil
		}

		prop, err := schema.GetPropertyByName(class, string(propName))
		if err != nil {
			return err
		}

		if isUUIDType(prop.DataType[0]) {
			return fmt.Errorf("prop %q is of type uuid/uuid[]: "+

View on GitHub (pinned to 75aa4b6d11)

Solutions

  1. Set path to a single property name present on the queried class, e.g. path: ["title"].
  2. Guard the query builder: if the sort property is empty, drop the sort clause.
  3. Validate sort input at the API boundary before forwarding to the GraphQL layer.

Example fix

// before
sort: [{path: [], order: asc}]
// after
sort: [{path: ["title"], order: asc}]
Defensive patterns

Strategy: validation

Validate before calling

for _, clause := range sort {
  if len(clause.Path) == 0 {
    return errors.New("each sort clause needs a non-empty path, e.g. [\"title\"]")
  }
}

Type guard

func hasSortPath(s filters.Sort) bool { return len(s.Path) > 0 }

Try / catch

if err := filters.ValidateSort(getClass, class, sort); err != nil {
  if strings.Contains(err.Error(), "path parameter cannot be empty") {
    return errors.New("sort.path must contain a property name")
  }
  return err
}

Prevention

When it happens

Trigger: A GraphQL sort clause like {path: [], order: asc}; path was stripped to zero elements during parsing; client built the path from a variable that resolved to an empty list.

Common situations: Dynamic query builders that join property names and produce [] when no sort property was selected.

Related errors


AI-assisted analysis of weaviate/weaviate@75aa4b6d11 (2026-09-04). Data as JSON: /api/errors/df93f91fc48b9efd. Report an issue: GitHub.