{"record":{"id":"df93f91fc48b9efd","repo":"weaviate/weaviate","slug":"path-parameter-cannot-be-empty-df93f9","errorCode":null,"errorMessage":"path parameter cannot be empty","messagePattern":"path parameter cannot be empty","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"entities/filters/sort_validator.go","lineNumber":52,"sourceCode":"\tif len(errs) > 0 {\n\t\treturn mergeErrs(errs)\n\t} else {\n\t\treturn nil\n\t}\n}\n\nfunc validateSortClause(getClass func(string) *models.Class, className schema.ClassName, sort Sort) error {\n\t// validate current\n\tpath, order := sort.Path, sort.Order\n\n\tif len(order) > 0 && order != \"asc\" && order != \"desc\" {\n\t\treturn errors.Errorf(`invalid order parameter, `+\n\t\t\t`possible values are: [\"asc\", \"desc\"] not: \"%s\"`, order)\n\t}\n\n\tswitch len(path) {\n\tcase 0:\n\t\treturn errors.New(\"path parameter cannot be empty\")\n\tcase 1:\n\t\tclass := getClass(className.String())\n\t\tif class == nil {\n\t\t\treturn errors.Errorf(\"class %q does not exist in schema\", className)\n\t\t}\n\t\tpropName := schema.PropertyName(path[0])\n\t\tif IsInternalProperty(propName) {\n\t\t\t// handle internal properties\n\t\t\treturn nil\n\t\t}\n\n\t\tprop, err := schema.GetPropertyByName(class, string(propName))\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\tif isUUIDType(prop.DataType[0]) {\n\t\t\treturn fmt.Errorf(\"prop %q is of type uuid/uuid[]: \"+","sourceCodeStart":34,"sourceCodeEnd":70,"githubUrl":"https://github.com/weaviate/weaviate/blob/75aa4b6d11f8818305aafd4440b4e32794f7ca04/entities/filters/sort_validator.go#L34-L70","documentation":"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.","triggerScenarios":"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.","commonSituations":"Dynamic query builders that join property names and produce [] when no sort property was selected.","solutions":["Set path to a single property name present on the queried class, e.g. path: [\"title\"].","Guard the query builder: if the sort property is empty, drop the sort clause.","Validate sort input at the API boundary before forwarding to the GraphQL layer."],"exampleFix":"// before\nsort: [{path: [], order: asc}]\n// after\nsort: [{path: [\"title\"], order: asc}]","handlingStrategy":"validation","validationCode":"for _, clause := range sort {\n  if len(clause.Path) == 0 {\n    return errors.New(\"each sort clause needs a non-empty path, e.g. [\\\"title\\\"]\")\n  }\n}","typeGuard":"func hasSortPath(s filters.Sort) bool { return len(s.Path) > 0 }","tryCatchPattern":"if err := filters.ValidateSort(getClass, class, sort); err != nil {\n  if strings.Contains(err.Error(), \"path parameter cannot be empty\") {\n    return errors.New(\"sort.path must contain a property name\")\n  }\n  return err\n}","preventionTips":["Reject empty paths in query builders before sending.","Type sort paths as non-empty string arrays in your client SDK.","Test dynamic sort construction with missing sort-property inputs."],"tags":["sort","validation","graphql"],"backgroundTag":"empty-sort-path","analyzedSha":"75aa4b6d11f8818305aafd4440b4e32794f7ca04","analyzedAt":"2026-09-04T14:58:20.392Z","contentChangedAt":"2026-09-04T14:58:20.392Z","schemaVersion":2},"datasetVersion":"2026-09-11T21:17:09.523Z"}