{"record":{"id":"56f24064aacf31d1","repo":"jaegertracing/jaeger","slug":"service-name-must-be-set-56f240","errorCode":null,"errorMessage":"service Name must be set","messagePattern":"service Name must be set","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/storage/v1/cassandra/spanstore/reader.go","lineNumber":66,"sourceCode":"\t\tFROM service_operation_index\n\t\tWHERE service_name = ? AND operation_name = ? AND start_time > ? AND start_time < ?\n\t\tORDER BY start_time DESC\n\t\tLIMIT ?`\n\tqueryByDuration = `\n\t\tSELECT trace_id\n\t\tFROM duration_index\n\t\tWHERE bucket = ? AND service_name = ? AND operation_name = ? AND duration >= ? AND duration <= ?\n\t\tLIMIT ?`\n\n\tdefaultNumTraces = 100\n\t// limitMultiple exists because many spans that are returned from indices can have the same trace, limitMultiple increases\n\t// the number of responses from the index, so we can respect the user's limit value they provided.\n\tlimitMultiple = 3\n)\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(\"start Time Minimum is above Maximum\")\n\n\t// ErrDurationMinGreaterThanMax occurs when duration min is above duration max\n\tErrDurationMinGreaterThanMax = errors.New(\"duration Minimum is above Maximum\")\n\n\t// ErrMalformedRequestObject occurs when a request object is nil\n\tErrMalformedRequestObject = errors.New(\"malformed request object\")\n\n\t// ErrDurationAndTagQueryNotSupported occurs when duration and tags are both set\n\tErrDurationAndTagQueryNotSupported = errors.New(\"cannot query for duration and tags simultaneously\")\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\ntype serviceNamesReader func() ([]string, error)","sourceCodeStart":48,"sourceCodeEnd":84,"githubUrl":"https://github.com/jaegertracing/jaeger/blob/806f4447841ecdb60519f408b004a599d515f437/internal/storage/v1/cassandra/spanstore/reader.go#L48-L84","documentation":"ErrServiceNameNotSet is returned by validateQuery in the Cassandra span reader when FindTraceIDs/FindTraces is called with a TraceQueryParams whose ServiceName is empty. Every search index is keyed by service name, so a query without one would scan an empty partition key and return zero rows indistinguishable from 'no traces'. The reader refuses the query instead; note it is wrapped with errors.ErrUnsupported since RFC 0013 §3.3.","triggerScenarios":"Calling SpanReader.FindTraceIDs or FindTraces with &tracestore.TraceQueryParams{...} where p.ServiceName == \"\" — typically when the caller builds a query from a request that omitted the service field.","commonSituations":"An API/gRPC client sends a search request without serviceName; a UI widget submits an empty service filter; custom tooling calling the storage layer directly without validating the query first.","solutions":["Set ServiceName on the TraceQueryParams before calling FindTraces/FindTraceIDs.","Validate the incoming query at the API boundary and reject requests with an empty service name with a clear client-facing message.","If 'all services' search is intended, use the dedicated service/operation listing APIs (GetServices/GetOperations) rather than a trace query without a service."],"exampleFix":"// before\nreader.FindTraces(ctx, &tracestore.TraceQueryParams{StartTimeMin: t0, StartTimeMax: t1})\n// after\nreader.FindTraces(ctx, &tracestore.TraceQueryParams{ServiceName: \"payments\", StartTimeMin: t0, StartTimeMax: t1})","handlingStrategy":"validation","validationCode":"if query == nil || query.ServiceName == \"\" {\n    return errors.New(\"service name is required for trace search\")\n}","typeGuard":null,"tryCatchPattern":"ids, err := reader.FindTraceIDs(ctx, q)\nif errors.Is(err, spanstore.ErrServiceNameNotSet) {\n    return http.StatusBadRequest // or surface 'service name required' to the client\n}","preventionTips":["Reject empty service names at the API/gRPC boundary before reaching the storage layer.","Use the service/operation listing APIs when searching 'all services'.","Note the error wraps errors.ErrUnsupported — check both with errors.Is."],"tags":["cassandra","query-validation","trace-search"],"backgroundTag":"missing-required-argument","analyzedSha":"806f4447841ecdb60519f408b004a599d515f437","analyzedAt":"2026-09-01T02:39:22.140Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}