{"record":{"id":"f1df41a2b942a3b2","repo":"SigNoz/signoz","slug":"params-and-builderquery-cannot-be-nil","errorCode":null,"errorMessage":"params and builderQuery cannot be nil","messagePattern":"params and builderQuery cannot be nil","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/query-service/app/querier/helper.go","lineNumber":31,"sourceCode":"\t\"github.com/SigNoz/signoz/pkg/query-service/constants\"\n\tv3 \"github.com/SigNoz/signoz/pkg/query-service/model/v3\"\n\t\"github.com/SigNoz/signoz/pkg/query-service/postprocess\"\n\t\"github.com/SigNoz/signoz/pkg/query-service/querycache\"\n\t\"github.com/SigNoz/signoz/pkg/valuer\"\n)\n\nfunc prepareLogsQuery(\n\t_ context.Context,\n\tstart,\n\tend int64,\n\tbuilderQuery *v3.BuilderQuery,\n\tparams *v3.QueryRangeParamsV3,\n) (string, error) {\n\tquery := \"\"\n\tlogsQueryBuilder := logsV4.PrepareLogsQuery\n\n\tif params == nil || builderQuery == nil {\n\t\treturn query, fmt.Errorf(\"params and builderQuery cannot be nil\")\n\t}\n\n\t// for ts query with limit replace it as it is already formed\n\tif params.CompositeQuery.PanelType == v3.PanelTypeGraph && builderQuery.Limit > 0 && len(builderQuery.GroupBy) > 0 {\n\t\tlimitQuery, err := logsQueryBuilder(\n\t\t\tstart,\n\t\t\tend,\n\t\t\tparams.CompositeQuery.QueryType,\n\t\t\tparams.CompositeQuery.PanelType,\n\t\t\tbuilderQuery,\n\t\t\tv3.QBOptions{GraphLimitQtype: constants.FirstQueryGraphLimit},\n\t\t)\n\t\tif err != nil {\n\t\t\treturn query, err\n\t\t}\n\t\tplaceholderQuery, err := logsQueryBuilder(\n\t\t\tstart,\n\t\t\tend,","sourceCodeStart":13,"sourceCodeEnd":49,"githubUrl":"https://github.com/SigNoz/signoz/blob/5069bf80b08f1f00d7e014eccc09902f9871004f/pkg/query-service/app/querier/helper.go#L13-L49","documentation":"Internal guard in prepareLogsQuery: both the QueryRangeParamsV3 and the individual builder query must be non-nil before a logs query can be built. A nil pointer here means upstream constructed an invalid call into runBuilderQuery.","triggerScenarios":"Not typically reachable via normal HTTP; occurs when internal code or tests invoke runBuilderQuery with a nil params or a composite query missing that query name.","commonSituations":"Unit tests passing nil; programmatic use of the querier package; races where builderQueries map entries are removed during execution.","solutions":["If you see this in logs, check for a nil compositeQuery or missing builder query entry before calling the querier","In tests, always construct full QueryRangeParamsV3 with at least one builder query","Report upstream if triggered via the standard API (would indicate a server bug)"],"exampleFix":"// before\nrunBuilderQuery(ctx, \"q1\", nil, nil)\n// after\nparams := &v3.QueryRangeParamsV3{CompositeQuery: &v3.CompositeQuery{BuilderQueries: map[string]*v3.BuilderQuery{\"q1\": {}}}}\nrunBuilderQuery(ctx, \"q1\", params.BuilderQueries[\"q1\"], params)","handlingStrategy":"validation","validationCode":"if params == nil || params.CompositeQuery == nil { return errors.New(\"params with composite query required\") }\nif q, ok := params.CompositeQuery.BuilderQueries[name]; !ok || q == nil { return fmt.Errorf(\"builder query %q missing\", name) }","typeGuard":"func hasBuilderQuery(p *v3.QueryRangeParamsV3, name string) bool { return p != nil && p.CompositeQuery != nil && p.CompositeQuery.BuilderQueries[name] != nil }","tryCatchPattern":null,"preventionTips":["Never call the querier with partially built params; construct via ParseQueryRangeParams","In tests, use builders that guarantee non-nil maps"],"tags":["signoz","logs","nil-pointer","internal-error"],"backgroundTag":"nil-pointer-argument","analyzedSha":"5069bf80b08f1f00d7e014eccc09902f9871004f","analyzedAt":"2026-08-28T06:22:12.824Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}