{"record":{"id":"6e5cc54c517d6a29","repo":"SigNoz/signoz","slug":"invalid-data-source-s","errorCode":null,"errorMessage":"invalid data source: %s","messagePattern":"invalid data source: (.+?)","errorType":"validation","errorClass":null,"httpStatus":400,"severity":"error","filePath":"pkg/query-service/model/v3/v3.go","lineNumber":36,"sourceCode":"\n\tqbtypes \"github.com/SigNoz/signoz/pkg/types/querybuildertypes/querybuildertypesv5\"\n)\n\ntype DataSource string\n\nconst (\n\tDataSourceTraces  DataSource = \"traces\"\n\tDataSourceLogs    DataSource = \"logs\"\n\tDataSourceMetrics DataSource = \"metrics\"\n\tDataSourceMeter   DataSource = \"meter\"\n)\n\nfunc (d DataSource) Validate() error {\n\tswitch d {\n\tcase DataSourceTraces, DataSourceLogs, DataSourceMetrics, DataSourceMeter:\n\t\treturn nil\n\tdefault:\n\t\treturn fmt.Errorf(\"invalid data source: %s\", d)\n\t}\n}\n\ntype AggregateOperator string\n\nconst (\n\tAggregateOperatorNoOp          AggregateOperator = \"noop\"\n\tAggregateOperatorCount         AggregateOperator = \"count\"\n\tAggregateOperatorCountDistinct AggregateOperator = \"count_distinct\"\n\tAggregateOperatorSum           AggregateOperator = \"sum\"\n\tAggregateOperatorAvg           AggregateOperator = \"avg\"\n\tAggregateOperatorMin           AggregateOperator = \"min\"\n\tAggregateOperatorMax           AggregateOperator = \"max\"\n\tAggregateOperatorP05           AggregateOperator = \"p05\"\n\tAggregateOperatorP10           AggregateOperator = \"p10\"\n\tAggregateOperatorP20           AggregateOperator = \"p20\"\n\tAggregateOperatorP25           AggregateOperator = \"p25\"\n\tAggregateOperatorP50           AggregateOperator = \"p50\"","sourceCodeStart":18,"sourceCodeEnd":54,"githubUrl":"https://github.com/SigNoz/signoz/blob/5069bf80b08f1f00d7e014eccc09902f9871004f/pkg/query-service/model/v3/v3.go#L18-L54","documentation":"DataSource.Validate accepts only traces, logs, metrics, and meter data sources. Any other string (typo, empty, or a source not supported by this build) is rejected. It is called from other Validate methods, so it often surfaces as part of query/rule validation.","triggerScenarios":"Constructing a query or rule JSON with dataSource set to something like 'Trace', '', 'spans', or an unshipped source; also when a composite query's data source doesn't match one of the v3 constants.","commonSituations":"Hand-written API payloads with wrong casing; enum drift between a custom frontend and the query-service version; copy-pasting examples that reference non-existent sources.","solutions":["Use exactly one of: traces, logs, metrics, meter (the v3.DataSource constants)","Check the DataSource constants in pkg/query-service/model/v3 for the supported list in your version","Upgrade/downgrade align client and server enums"],"exampleFix":"// before\n{\"dataSource\":\"Trace\",\"compositeQuery\":...}\n\n// after\n{\"dataSource\":\"traces\",\"compositeQuery\":...}","handlingStrategy":"type-guard","validationCode":"if err := ds.Validate(); err != nil {\n    return fmt.Errorf(\"bad data source: %v\", err)\n}","typeGuard":"func isValidDataSource(d v3.DataSource) bool {\n    switch d {\n    case v3.DataSourceTraces, v3.DataSourceLogs, v3.DataSourceMetrics, v3.DataSourceMeter:\n        return true\n    }\n    return false\n}","tryCatchPattern":null,"preventionTips":["Use generated constants/enums instead of hand-typed strings","Add schema validation (JSON Schema) for external query payloads"],"tags":["signoz","data-source","validation","enum"],"backgroundTag":"invalid-enum-value","analyzedSha":"5069bf80b08f1f00d7e014eccc09902f9871004f","analyzedAt":"2026-08-28T06:22:12.824Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}