{"record":{"id":"2ad79825f8bf8085","repo":"jaegertracing/jaeger","slug":"cannot-query-for-duration-and-tags-simultaneously","errorCode":null,"errorMessage":"cannot query for duration and tags simultaneously","messagePattern":"cannot query for duration and tags simultaneously","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/storage/v1/cassandra/spanstore/reader.go","lineNumber":78,"sourceCode":"\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)\n\ntype operationNamesReader func(query tracestore.OperationQueryParams) ([]tracestore.Operation, error)\n\ntype spanReaderMetrics struct {\n\treadTraces                 *casmetrics.Table\n\tqueryTrace                 *casmetrics.Table\n\tqueryTagIndex              *casmetrics.Table\n\tqueryDurationIndex         *casmetrics.Table\n\tqueryServiceOperationIndex *casmetrics.Table\n\tqueryServiceNameIndex      *casmetrics.Table\n}\n","sourceCodeStart":60,"sourceCodeEnd":96,"githubUrl":"https://github.com/jaegertracing/jaeger/blob/806f4447841ecdb60519f408b004a599d515f437/internal/storage/v1/cassandra/spanstore/reader.go#L60-L96","documentation":"ErrDurationAndTagQueryNotSupported is returned by validateQuery when the query sets a duration filter (DurationMin or DurationMax non-zero) and also supplies search attributes/tags. The Cassandra schema indexes tags separately from duration-derived rows, so combining both filters in one query is not supported by this storage backend and is rejected up front.","triggerScenarios":"FindTraces/FindTraceIDs called with TraceQueryParams where (DurationMin != 0 || DurationMax != 0) and p.Attributes.Len() > 0 — e.g. a search request like 'duration>1s AND tag http.status_code=500'.","commonSituations":"UI/API clients composing arbitrary search filters that the storage layer cannot satisfy jointly; feature-parity assumptions between the ES backend (which supports the combination) and the Cassandra backend; plugin code forwarding user filter objects unmodified.","solutions":["Run the query in two passes: first filter by duration (or tags) via FindTraceIDs, then narrow results by the other criterion in application code.","Drop one of the two filters if the results of a single filter are sufficient.","If the combination is a hard requirement, use the Elasticsearch/OpenSearch storage backend, which supports duration+tag queries."],"exampleFix":"// before\nq := &tracestore.TraceQueryParams{DurationMin: time.Second, Attributes: tags}\nreader.FindTraces(ctx, q) // rejected\n// after: query duration first, filter tags client-side\nids, _ := reader.FindTraceIDs(ctx, &tracestore.TraceQueryParams{ServiceName: svc, DurationMin: time.Second, ...})\n// then filter matching traces by tags","handlingStrategy":"validation","validationCode":"if (q.DurationMin != 0 || q.DurationMax != 0) && q.Attributes.Len() > 0 {\n    return errors.New(\"cassandra backend: cannot combine duration and tag filters\")\n}","typeGuard":null,"tryCatchPattern":"ids, err := reader.FindTraceIDs(ctx, q)\nif errors.Is(err, spanstore.ErrDurationAndTagQueryNotSupported) {\n    // degrade: run one filter, refine client-side, or inform user of backend limit\n}","preventionTips":["Feature-detect storage capabilities and disable combined duration+tag search in the UI for Cassandra backends.","Split such queries into two passes (duration query, then tag refinement) in a shared search helper.","Document backend-specific query limitations for API consumers."],"tags":["cassandra","query-validation","unsupported-feature"],"backgroundTag":"unsupported-query-combination","analyzedSha":"806f4447841ecdb60519f408b004a599d515f437","analyzedAt":"2026-09-01T02:39:22.140Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}