{"record":{"id":"0df5ffc33d8c469c","repo":"jaegertracing/jaeger","slug":"service-name-must-be-set","errorCode":null,"errorMessage":"service name must be set","messagePattern":"service name must be set","errorType":"validation","errorClass":null,"httpStatus":400,"severity":"error","filePath":"internal/storage/v1/badger/spanstore/reader.go","lineNumber":28,"sourceCode":"\t\"encoding/json\"\n\t\"errors\"\n\t\"fmt\"\n\t\"math\"\n\t\"slices\"\n\n\t\"github.com/dgraph-io/badger/v4\"\n\t\"golang.org/x/exp/maps\"\n\n\t\"github.com/jaegertracing/jaeger-idl/model/v1\"\n\t\"github.com/jaegertracing/jaeger/internal/storage/v1/api/spanstore\"\n\t\"github.com/jaegertracing/jaeger/internal/storage/v2/api/tracestore\"\n)\n\n// Most of these errors are common with the ES and Cassandra backends. Each backend has slightly different validation rules.\n\nvar (\n\t// ErrServiceNameNotSet occurs when attempting to query with an empty service name\n\tErrServiceNameNotSet = errors.New(\"service name must be set\")\n\n\t// ErrStartTimeMinGreaterThanMax occurs when start time min is above start time max\n\tErrStartTimeMinGreaterThanMax = errors.New(\"min start time is above max\")\n\n\t// ErrDurationMinGreaterThanMax occurs when duration min is above duration max\n\tErrDurationMinGreaterThanMax = errors.New(\"min duration is above max\")\n\n\t// ErrMalformedRequestObject occurs when a request object is nil\n\tErrMalformedRequestObject = errors.New(\"malformed request object\")\n\n\t// ErrStartAndEndTimeNotSet occurs when start time and end time are not set\n\tErrStartAndEndTimeNotSet = errors.New(\"start and end time must be set\")\n\n\t// ErrUnableToFindTraceIDAggregation occurs when an aggregation query for TraceIDs fail.\n\tErrUnableToFindTraceIDAggregation = errors.New(\"could not find aggregation of traceIDs\")\n\n\t// ErrNotSupported during development, don't support every option - yet\n\tErrNotSupported = errors.New(\"this query parameter is not supported yet\")","sourceCodeStart":10,"sourceCodeEnd":46,"githubUrl":"https://github.com/jaegertracing/jaeger/blob/806f4447841ecdb60519f408b004a599d515f437/internal/storage/v1/badger/spanstore/reader.go#L10-L46","documentation":"ErrServiceNameNotSet is returned by the badger spanstore's validateQuery when a FindTraces/FindTraceIDs query supplies tags or an operation name without a service name. In the badger backend, service name is a required component of the index keys, so such a query cannot be executed. Other backends (ES, Cassandra) declare equivalent errors with slightly different validation rules.","triggerScenarios":"Calling FindTraceIDs/FindTraces with TraceQueryParameters where ServiceName == \"\" while Tags is non-empty or OperationName != \"\"; e.g. a search form that only fills in an operation or tag filter.","commonSituations":"Query UI/API callers omitting the service dropdown; API clients building search requests programmatically and assuming tags alone are enough; older clients relying on backend-specific behavior.","solutions":["Set query.ServiceName before adding OperationName or Tags to the search parameters.","If you only have tags, first discover candidate services via GetServices or by including the service name from span context.","Update API clients/UI to always send the service field for operation- or tag-scoped searches."],"exampleFix":"// before\nq := &spanstore.TraceQueryParameters{OperationName: \"GET /api\", Tags: tags}\nids, err := reader.FindTraceIDs(ctx, q)\n// after\nq := &spanstore.TraceQueryParameters{ServiceName: \"frontend\", OperationName: \"GET /api\", Tags: tags}\nids, err := reader.FindTraceIDs(ctx, q)","handlingStrategy":"validation","validationCode":"func validateBadgerQuery(q *spanstore.TraceQueryParameters) error {\n\tif q == nil {\n\t\treturn errors.New(\"query is nil\")\n\t}\n\tif q.ServiceName == \"\" && (q.OperationName != \"\" || len(q.Tags) > 0) {\n\t\treturn errors.New(\"service name is required when filtering by operation or tags\")\n\t}\n\treturn nil\n}","typeGuard":null,"tryCatchPattern":"ids, err := reader.FindTraceIDs(ctx, q)\nif errors.Is(err, spanstore.ErrServiceNameNotSet) {\n\treturn nil, httpError(400, \"service name is required for this search\")\n}\nif err != nil { return nil, err }","preventionTips":["Make service name a mandatory field in search forms and API requests that include operation/tag filters.","Pre-flight validate queries client-side so the user fixes the form instead of seeing a 500.","Mirror backend validation rules in shared request-validators to keep badger/ES/Cassandra behavior consistent."],"tags":["go","badger","query-validation","spanstore"],"backgroundTag":"missing-required-argument","analyzedSha":"806f4447841ecdb60519f408b004a599d515f437","analyzedAt":"2026-09-01T02:39:22.140Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}