{"record":{"id":"0becb8fdd695dce7","repo":"SigNoz/signoz","slug":"codenotfound-0becb8","errorCode":"CodeNotFound","errorMessage":"no spans found matching the specified criteria","messagePattern":"no spans found matching the specified criteria","errorType":"error_code","errorClass":null,"httpStatus":404,"severity":"warning","filePath":"pkg/modules/spanpercentile/implspanpercentile/module.go","lineNumber":55,"sourceCode":"\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tif err := queryRangeRequest.Validate(); err != nil {\n\t\treturn nil, err\n\t}\n\n\tresult, err := m.querier.QueryRange(ctx, orgID, queryRangeRequest)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn transformToSpanPercentileResponse(result)\n}\n\nfunc transformToSpanPercentileResponse(queryResult *qbtypes.QueryRangeResponse) (*spanpercentiletypes.SpanPercentileResponse, error) {\n\tif len(queryResult.Data.Results) == 0 {\n\t\treturn nil, errors.New(errors.TypeNotFound, errors.CodeNotFound, \"no spans found matching the specified criteria\")\n\t}\n\n\tscalarData, ok := queryResult.Data.Results[0].(*qbtypes.ScalarData)\n\tif !ok {\n\t\treturn nil, errors.New(errors.TypeInternal, errors.CodeInternal, \"unexpected result type\")\n\t}\n\n\tif len(scalarData.Data) == 0 {\n\t\treturn nil, errors.New(errors.TypeNotFound, errors.CodeNotFound, \"no spans found matching the specified criteria\")\n\t}\n\n\trow := scalarData.Data[0]\n\n\tcolumnMap := make(map[string]int)\n\tfor i, col := range scalarData.Columns {\n\t\tcolumnMap[col.Name] = i\n\t}\n","sourceCodeStart":37,"sourceCodeEnd":73,"githubUrl":"https://github.com/SigNoz/signoz/blob/5069bf80b08f1f00d7e014eccc09902f9871004f/pkg/modules/spanpercentile/implspanpercentile/module.go#L37-L73","documentation":"Thrown by GetSpanPercentile in the spanpercentile module when the underlying query returns zero result series. The transform step treats an empty query result as 'not found' rather than returning an empty response. This typically means no spans matched the supplied trace/span filters or time range.","triggerScenarios":"Calling GetSpanPercentile with filters (service name, operation, trace ID, time range) that match no spans in the query backend; querying a time window before data was ingested.","commonSituations":"Wrong or misspelled service/operation name in filters, timestamps in the wrong format/timezone, querying an environment with no traffic, or insufficiently broad start/end times.","solutions":["Verify the service name, operation, and time range actually have ingested spans","Widen the start/end time window and re-issue the request","Check the span filters for typos or wrong casing","Confirm the ClickHouse/query backend has data for that period"],"exampleFix":"// before\nresp, err := module.GetSpanPercentile(ctx, spanID, startTime, endTime)\n// after\n// ensure time range covers the span; verify span exists via trace API first\nresp, err := module.GetSpanPercentile(ctx, spanID, startTime.Add(-time.Minute), endTime.Add(time.Minute))","handlingStrategy":"try-catch","validationCode":"// Verify spans exist for the window before requesting percentiles\nexists, err := spanStore.HasSpans(ctx, filter, start, end)\nif err != nil || !exists {\n    return fmt.Errorf(\"no spans in window: %w\", err)\n}","typeGuard":"func isNotFoundErr(err error) bool {\n    var e *errors.Error\n    return errors.As(err, &e) && e.Code == errors.CodeNotFound\n}","tryCatchPattern":"resp, err := module.GetSpanPercentile(ctx, spanID, start, end)\nif err != nil {\n    if isNotFoundErr(err) {\n        // degrade gracefully: show \"no data\" in UI\n        return emptyPercentile(), nil\n    }\n    return nil, err\n}","preventionTips":["Validate time range and filters before querying","Confirm the trace/span exists via a trace lookup first","Treat CodeNotFound from percentile APIs as empty-state, not a failure"],"tags":["spanpercentile","not-found","query","go","observability"],"backgroundTag":"no-query-results","analyzedSha":"5069bf80b08f1f00d7e014eccc09902f9871004f","analyzedAt":"2026-08-28T06:22:12.824Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}