{"record":{"id":"a2e45849a9b03e02","repo":"jaegertracing/jaeger","slug":"malformed-request-object","errorCode":null,"errorMessage":"malformed request object","messagePattern":"malformed request object","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/storage/v1/badger/spanstore/reader.go","lineNumber":37,"sourceCode":"\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\")\n\n\t// ErrInternalConsistencyError indicates internal data consistency issue\n\tErrInternalConsistencyError = errors.New(\"internal data consistency issue\")\n)\n\nconst (\n\tdefaultNumTraces = 100\n\tsizeOfTraceID    = 16\n\tencodingTypeBits = 0x0F","sourceCodeStart":19,"sourceCodeEnd":55,"githubUrl":"https://github.com/jaegertracing/jaeger/blob/806f4447841ecdb60519f408b004a599d515f437/internal/storage/v1/badger/spanstore/reader.go#L19-L55","documentation":"ErrMalformedRequestObject is returned by validateQuery when the *spanstore.TraceQueryParameters pointer passed to FindTraces/FindTraceIDs is nil. A nil query object has no bounds or filters at all, so the reader refuses it instead of panicking on field access.","triggerScenarios":"Calling FindTraceIDs(ctx, nil) or FindTraces(ctx, nil) directly — most often from hand-written integrations or test code that builds the request conditionally and skips the nil case.","commonSituations":"Wrappers that pass through a decoded request body which failed to bind; generic adapters constructing the params only when filters exist; unit tests passing nil expecting an empty result.","solutions":["Always pass a non-nil *spanstore.TraceQueryParameters; use an empty struct for 'match everything recent'.","Check for nil in your caller before invoking the reader and return a client-side validation error.","At an API boundary, default an empty request to &spanstore.TraceQueryParameters{StartTimeMin: ..., StartTimeMax: ...} with sane bounds."],"exampleFix":"// before\nids, err := reader.FindTraceIDs(ctx, nil)\n// after\nif query == nil {\n\tquery = &spanstore.TraceQueryParameters{\n\t\tStartTimeMin: time.Now().Add(-time.Hour),\n\t\tStartTimeMax: time.Now(),\n\t}\n}\nids, err := reader.FindTraceIDs(ctx, query)","handlingStrategy":"validation","validationCode":"if q == nil {\n\treturn errors.New(\"trace query parameters must not be nil\")\n}","typeGuard":"func isUsableQuery(q *spanstore.TraceQueryParameters) bool {\n\treturn q != nil\n}","tryCatchPattern":"ids, err := reader.FindTraceIDs(ctx, q)\nif errors.Is(err, spanstore.ErrMalformedRequestObject) {\n\treturn nil, httpError(400, \"missing query parameters\")\n}\nif err != nil { return nil, err }","preventionTips":["Never pass a nil *TraceQueryParameters; default to an empty struct with explicit time bounds.","Default an empty/missing request body to a sensible query at the API boundary.","Handle decode/bind failures before constructing the storage query so nils cannot leak through."],"tags":["go","badger","nil-check","query-validation"],"backgroundTag":"nil-pointer-argument","analyzedSha":"806f4447841ecdb60519f408b004a599d515f437","analyzedAt":"2026-09-01T02:39:22.140Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}