{"record":{"id":"86650b264529cd5a","repo":"SigNoz/signoz","slug":"query-name-is-required","errorCode":null,"errorMessage":"query name is required","messagePattern":"query name is required","errorType":"validation","errorClass":null,"httpStatus":400,"severity":"error","filePath":"pkg/query-service/model/v3/v3.go","lineNumber":1025,"sourceCode":"\t\t\treturn true\n\t\t}\n\tcase DataSourceTraces, DataSourceLogs:\n\t\tif b.AggregateOperator.IsRateOperator() ||\n\t\t\tb.AggregateOperator == AggregateOperatorCount ||\n\t\t\tb.AggregateOperator == AggregateOperatorCountDistinct {\n\t\t\treturn true\n\t\t}\n\t}\n\treturn false\n}\n\nfunc (b *BuilderQuery) Validate(panelType PanelType) error {\n\tif b == nil {\n\t\treturn nil\n\t}\n\n\tif b.QueryName == \"\" {\n\t\treturn fmt.Errorf(\"query name is required\")\n\t}\n\n\t// if expression is same as query name, it's a simple builder query and not a formula\n\t// formula involves more than one data source, aggregate operator, etc.\n\tif b.QueryName == b.Expression {\n\t\tif err := b.DataSource.Validate(); err != nil {\n\t\t\treturn fmt.Errorf(\"data source is invalid: %w\", err)\n\t\t}\n\t\tif b.DataSource == DataSourceMetrics {\n\t\t\t// if AggregateOperator is specified, then the request is using v3 payload\n\t\t\t// if b.AggregateOperator != \"\" && b.SpaceAggregation == SpaceAggregationUnspecified {\n\t\t\t// \tif err := b.AggregateOperator.Validate(); err != nil {\n\t\t\t// \t\treturn fmt.Errorf(\"aggregate operator is invalid: %w\", err)\n\t\t\t// \t}\n\t\t\t// } else {\n\t\t\t// \t// the time aggregation is not needed for percentile operators\n\t\t\t// \tif !IsPercentileOperator(b.SpaceAggregation) {\n\t\t\t// \t\tif err := b.TimeAggregation.Validate(); err != nil {","sourceCodeStart":1007,"sourceCodeEnd":1043,"githubUrl":"https://github.com/SigNoz/signoz/blob/5069bf80b08f1f00d7e014eccc09902f9871004f/pkg/query-service/model/v3/v3.go#L1007-L1043","documentation":"BuilderQuery.Validate requires a non-empty QueryName; it is the map key and the identifier used in formulas.","triggerScenarios":"Posting a builder query whose queryName field is missing or empty string.","commonSituations":"Programmatically generating queries and forgetting to set queryName; copy-pasting JSON that dropped the field.","solutions":["Set queryName to a unique non-empty name like \"A1\"","For formulas, ensure the expression references existing query names"],"exampleFix":"// before\n{\"A\":{\"expression\":\"A\"}}\n// after\n{\"A\":{\"queryName\":\"A\",\"expression\":\"A\"}}","handlingStrategy":"validation","validationCode":"if strings.TrimSpace(q.QueryName) == \"\" { return errors.New(\"queryName is required\") }","typeGuard":"func hasQueryName(q v3.BuilderQuery) bool { return strings.TrimSpace(q.QueryName) != \"\" }","tryCatchPattern":null,"preventionTips":["Generate query names (A, B, C...) server-side when creating queries programmatically"],"tags":["go","required-field","builder-query"],"backgroundTag":"missing-required-field","analyzedSha":"5069bf80b08f1f00d7e014eccc09902f9871004f","analyzedAt":"2026-08-28T06:22:12.824Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}