{"record":{"id":"4d7ba150b48b19ce","repo":"jaegertracing/jaeger","slug":"malformed-request-object-4d7ba1","errorCode":null,"errorMessage":"malformed request object","messagePattern":"malformed request object","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/storage/v2/elasticsearch/tracestore/core/reader.go","lineNumber":62,"sourceCode":"\tnestedLogFieldsField   = \"logs.fields\"\n\ttagKeyField            = \"key\"\n\ttagValueField          = \"value\"\n\terrorTag               = \"error\"\n\n\tdefaultSearchDepth = 100\n\n\tDawnOfTimeSpanAge = time.Hour * 24 * 365 * 50\n)\n\nvar (\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// 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\tdefaultMaxDuration = model.DurationAsMicroseconds(time.Hour * 24)\n\n\tobjectTagFieldList = []string{objectTagsField, objectProcessTagsField}\n\n\tnestedTagFieldList = []string{nestedTagsField, nestedProcessTagsField, nestedLogFieldsField}\n\n\t_ Reader = (*SpanReader)(nil) // check API conformance\n)\n\n// Time-range design (referenced as \"timeRangeDesign\" in comments below):\n//","sourceCodeStart":44,"sourceCodeEnd":80,"githubUrl":"https://github.com/jaegertracing/jaeger/blob/806f4447841ecdb60519f408b004a599d515f437/internal/storage/v2/elasticsearch/tracestore/core/reader.go#L44-L80","documentation":"ErrMalformedRequestObject is a sentinel error returned by validateQuery when the request passed to the reader is nil. The Elasticsearch trace reader requires a non-nil query object to build its search request, so a nil input is reported as a malformed request instead of panicking with a nil dereference.","triggerScenarios":"Calling reader.FindTraceIDs(ctx, nil) or FindTraces(ctx, nil) with a nil query/params struct. validateQuery checks for the nil object first and returns this error.","commonSituations":"Constructing the query in a variable that failed to initialize (early error path left it nil); wiring a generic query handler that passes through a nil pointer from deserialization; tests forgetting to populate parameters.","solutions":["Pass a non-nil query object (e.g. &v2api.TraceQueryParameters{...}) to FindTraceIDs/FindTraces.","Check for nil in your caller before calling the reader and handle it as a client error.","If the query may legitimately be empty, pass a zero-value struct instead of nil."],"exampleFix":"// before\ntraceIDs, err := reader.FindTraceIDs(ctx, nil)\n// after\nif query == nil { return nil, ErrMalformedRequestObject }\ntraceIDs, err := reader.FindTraceIDs(ctx, query)","handlingStrategy":"type-guard","validationCode":"if query == nil {\n    return fmt.Errorf(\"query must be provided: %w\", core.ErrMalformedRequestObject)\n}","typeGuard":"func hasQuery(q *api.TraceQueryParameters) bool { return q != nil }\n\nif !hasQuery(query) { /* treat as client error */ }","tryCatchPattern":"traces, err := reader.FindTraces(ctx, query)\nif errors.Is(err, core.ErrMalformedRequestObject) {\n    return http.StatusBadRequest // nil request\n}","preventionTips":["Never pass nil structs; use zero-value literals (&TraceQueryParameters{}) for empty queries.","Validate deserialized requests for nil before forwarding to storage.","Initialize query objects in constructors so error paths cannot leave them nil."],"tags":["elasticsearch","nil-input","query-validation"],"backgroundTag":"nil-request-object","analyzedSha":"806f4447841ecdb60519f408b004a599d515f437","analyzedAt":"2026-09-01T02:39:22.140Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}