{"record":{"id":"9922ca5c1e6c866d","repo":"SigNoz/signoz","slug":"composite-query-is-required","errorCode":null,"errorMessage":"composite query is required","messagePattern":"composite query is required","errorType":"validation","errorClass":null,"httpStatus":400,"severity":"error","filePath":"pkg/query-service/model/v3/v3.go","lineNumber":610,"sourceCode":"\t}\n\treturn count\n}\n\nfunc (c *CompositeQuery) Sanitize() {\n\tif c == nil {\n\t\treturn\n\t}\n\t// remove groupBy for queries with list panel type\n\tfor _, query := range c.BuilderQueries {\n\t\tif len(query.GroupBy) > 0 && c.PanelType == PanelTypeList {\n\t\t\tquery.GroupBy = []AttributeKey{}\n\t\t}\n\t}\n}\n\nfunc (c *CompositeQuery) Validate() error {\n\tif c == nil {\n\t\treturn fmt.Errorf(\"composite query is required\")\n\t}\n\n\tif c.BuilderQueries == nil && c.ClickHouseQueries == nil && c.PromQueries == nil && len(c.Queries) == 0 {\n\t\treturn fmt.Errorf(\"composite query must contain at least one query type\")\n\t}\n\n\tif c.QueryType == QueryTypeBuilder {\n\t\tfor name, query := range c.BuilderQueries {\n\t\t\tif err := query.Validate(c.PanelType); err != nil {\n\t\t\t\treturn fmt.Errorf(\"builder query %s is invalid: %w\", name, err)\n\t\t\t}\n\t\t}\n\t}\n\n\tif c.QueryType == QueryTypeClickHouseSQL {\n\t\tfor name, query := range c.ClickHouseQueries {\n\t\t\tif err := query.Validate(); err != nil {\n\t\t\t\treturn fmt.Errorf(\"clickhouse query %s is invalid: %w\", name, err)","sourceCodeStart":592,"sourceCodeEnd":628,"githubUrl":"https://github.com/SigNoz/signoz/blob/5069bf80b08f1f00d7e014eccc09902f9871004f/pkg/query-service/model/v3/v3.go#L592-L628","documentation":"CompositeQuery.Validate() returns this when the CompositeQuery itself is nil. The server unmarshals the request body into *CompositeQuery; a missing/invalid compositeQuery section leaves it nil and validation fails immediately.","triggerScenarios":"POSTing /api/v3/query_range with a body that has no compositeQuery field at all, a malformed JSON body where unmarshalling silently leaves the struct nil, or passing a nil *v3.CompositeQuery programmatically to code that calls Validate().","commonSituations":"Client built against an older API shape without compositeQuery, JSON nesting errors (putting queryType at top level instead of inside compositeQuery), or code paths calling Validate on a zero-valued request.","solutions":["Ensure the request body contains a compositeQuery object with queryType, panelType, and at least one query collection","Verify JSON nesting matches the API schema: {\"compositeQuery\":{\"queryType\":\"builder\",...}}","Check the HTTP response/error for unmarshal issues if you believe you are sending it"],"exampleFix":"// before\n{\"queryType\":\"promql\",\"promQueries\":{\"A\":{\"query\":\"up\"}}}\n\n// after\n{\"compositeQuery\":{\"queryType\":\"promql\",\"panelType\":\"graph\",\"promQueries\":{\"A\":{\"query\":\"up\"}}}}","handlingStrategy":"validation","validationCode":"if cq == nil { return errors.New(\"compositeQuery is missing — check request body structure\") }","typeGuard":"func hasCompositeQuery(body []byte) bool { var b struct{ CompositeQuery *json.RawMessage `json:\"compositeQuery\"` }; _ = json.Unmarshal(body, &b); return b.CompositeQuery != nil }","tryCatchPattern":null,"preventionTips":["Nest queries under compositeQuery with the right JSON casing","Log the raw request body when validation unexpectedly fails"],"tags":["go","validation","missing-field","composite-query","signoz"],"backgroundTag":"missing-required-field","analyzedSha":"5069bf80b08f1f00d7e014eccc09902f9871004f","analyzedAt":"2026-08-28T06:22:12.824Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}