{"record":{"id":"aad7825654fa6013","repo":"SigNoz/signoz","slug":"errcodedashboardinvalidwidgetquery","errorCode":"ErrCodeDashboardInvalidWidgetQuery","errorMessage":"invalid query request","messagePattern":"invalid query request","errorType":"validation","errorClass":null,"httpStatus":400,"severity":"error","filePath":"pkg/types/dashboardtypes/dashboard.go","lineNumber":431,"sourceCode":"\t}\n\n\tqueryRangeReq := map[string]any{\n\t\t\"schemaVersion\": \"v1\",\n\t\t\"start\":         startTime,\n\t\t\"end\":           endTime,\n\t\t\"requestType\":   dashboard.getQueryRequestTypeFromPanelType(widgetData.PanelTypes),\n\t\t\"compositeQuery\": map[string]any{\n\t\t\t\"queries\": compositeQueries,\n\t\t},\n\t\t\"formatOptions\": map[string]any{\n\t\t\t\"fillGaps\":               widgetData.FillGaps,\n\t\t\t\"formatTableResultForUI\": widgetData.PanelTypes == \"table\",\n\t\t},\n\t}\n\n\treq, err := json.Marshal(queryRangeReq)\n\tif err != nil {\n\t\treturn nil, errors.Wrapf(err, errors.TypeInvalidInput, ErrCodeDashboardInvalidWidgetQuery, \"invalid query request\")\n\t}\n\n\tqueryRangeRequest := new(querybuildertypesv5.QueryRangeRequest)\n\terr = json.Unmarshal(req, queryRangeRequest)\n\tif err != nil {\n\t\treturn nil, errors.Wrapf(err, errors.TypeInvalidInput, ErrCodeDashboardInvalidWidgetQuery, \"invalid query request\")\n\t}\n\n\treturn queryRangeRequest, nil\n}\n\nfunc (dashboard *Dashboard) getQueryRequestTypeFromPanelType(panelType string) querybuildertypesv5.RequestType {\n\tswitch panelType {\n\tcase \"graph\", \"bar\":\n\t\treturn querybuildertypesv5.RequestTypeTimeSeries\n\tcase \"table\", \"pie\", \"value\":\n\t\treturn querybuildertypesv5.RequestTypeScalar\n\tcase \"trace\":","sourceCodeStart":413,"sourceCodeEnd":449,"githubUrl":"https://github.com/SigNoz/signoz/blob/5069bf80b08f1f00d7e014eccc09902f9871004f/pkg/types/dashboardtypes/dashboard.go#L413-L449","documentation":"GetWidgetQuery builds a QueryRangeRequest by marshalling an intermediate map (queryRangeReq) and unmarshalling into querybuildertypesv5.QueryRangeRequest. This first 'invalid query request' fires when that intermediate map cannot be marshalled — e.g. a value inside the request map is a func/chan or otherwise non-serializable.","triggerScenarios":"Invoking GetWidgetQuery where composed request values (from widget data) include a non-JSON-serializable Go value, causing json.Marshal(queryRangeReq) to fail.","commonSituations":"Programmatically built widget/query objects containing Go-native types; custom types in widget query data lacking proper serialization; edge-case composite data from integrations.","solutions":["Inspect the widget's query data and remove non-serializable values","Keep widget query data limited to plain JSON-compatible types","Wrap calls to GetWidgetQuery and log the widget definition when it fails"],"exampleFix":"// before\nreq[\"start\"] = someFunc\n\n// after\nreq[\"start\"] = \"now-1h\"","handlingStrategy":"validation","validationCode":"if _, err := json.Marshal(widgetQueryData); err != nil {\n    return fmt.Errorf(\"widget query data contains non-serializable values: %w\", err)\n}","typeGuard":null,"tryCatchPattern":"req, err := d.GetWidgetQuery(i, ...)\nif err != nil && strings.Contains(err.Error(), \"invalid query request\") {\n    return errors.New(\"widget query could not be converted to a QueryRangeRequest; check widget definition\")\n}","preventionTips":["Keep widget query fields to plain JSON types","Log the widget definition alongside the failure for diagnosis"],"tags":["dashboard","json-marshal","query-builder"],"backgroundTag":"json-marshal-failed","analyzedSha":"5069bf80b08f1f00d7e014eccc09902f9871004f","analyzedAt":"2026-08-28T06:22:12.824Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}