{"record":{"id":"3674fab6f4b79a48","repo":"SigNoz/signoz","slug":"errcodedashboardinvaliddata-3674fa","errorCode":"ErrCodeDashboardInvalidData","errorMessage":"invalid dashboard data","messagePattern":"invalid dashboard data","errorType":"validation","errorClass":null,"httpStatus":400,"severity":"error","filePath":"pkg/types/dashboardtypes/public_dashboard.go","lineNumber":123,"sourceCode":"\ttype dashboardData struct {\n\t\tWidgets []struct {\n\t\t\tPanelTypes string `json:\"panelTypes\"`\n\t\t\tQuery      struct {\n\t\t\t\tBuilder struct {\n\t\t\t\t\tQueryData          []map[string]any `json:\"queryData\"`\n\t\t\t\t\tQueryFormulas      []map[string]any `json:\"queryFormulas\"`\n\t\t\t\t\tQueryTraceOperator []map[string]any `json:\"queryTraceOperator\"`\n\t\t\t\t} `json:\"builder\"`\n\t\t\t\tClickhouseSQL []map[string]any `json:\"clickhouse_sql\"`\n\t\t\t\tPromQL        []map[string]any `json:\"promql\"`\n\t\t\t\tQueryType     string           `json:\"queryType\"`\n\t\t\t} `json:\"query\"`\n\t\t} `json:\"widgets\"`\n\t}\n\n\tdataJSON, err := json.Marshal(dashboard.Data)\n\tif err != nil {\n\t\treturn nil, errors.Wrapf(err, errors.TypeInvalidInput, ErrCodeDashboardInvalidData, \"invalid dashboard data\")\n\t}\n\n\tvar data dashboardData\n\terr = json.Unmarshal(dataJSON, &data)\n\tif err != nil {\n\t\treturn nil, errors.Wrapf(err, errors.TypeInvalidInput, ErrCodeDashboardInvalidData, \"invalid dashboard data\")\n\t}\n\n\tfor idx, widget := range data.Widgets {\n\t\tupdatedQueryData := []map[string]any{}\n\t\tfor _, queryData := range widget.Query.Builder.QueryData {\n\t\t\tupdatedQueryMap := map[string]any{}\n\t\t\tupdatedQueryMap[\"aggregations\"] = queryData[\"aggregations\"]\n\t\t\tupdatedQueryMap[\"legend\"] = queryData[\"legend\"]\n\t\t\tupdatedQueryMap[\"queryName\"] = queryData[\"queryName\"]\n\t\t\tupdatedQueryMap[\"expression\"] = queryData[\"expression\"]\n\t\t\tupdatedQueryMap[\"groupBy\"] = queryData[\"groupBy\"]\n\t\t\tupdatedQueryMap[\"dataSource\"] = queryData[\"dataSource\"]","sourceCodeStart":105,"sourceCodeEnd":141,"githubUrl":"https://github.com/SigNoz/signoz/blob/5069bf80b08f1f00d7e014eccc09902f9871004f/pkg/types/dashboardtypes/public_dashboard.go#L105-L141","documentation":"NewPublicDashboardDataFromDashboard marshals the dashboard's Data to JSON and unmarshals it into an internal dashboardData struct to sanitize widgets for public display. Failure at this first step (line 123) means dashboard.Data itself could not be serialized — essentially a marshaling failure of a Dashboard that was constructed programmatically rather than loaded from validated storage.","triggerScenarios":"Calling GetPublicData (or NewPublicDashboardDataFromDashboard directly) on a Dashboard whose Data contains values json.Marshal cannot handle: NaN/Inf float fields, channels, funcs, or cyclic references in panel data.","commonSituations":"Building a Dashboard struct in Go code with untyped map[string]any panel data containing unsupported values; dashboards assembled from templated generation code; unit fixtures with float NaN defaults.","solutions":["Inspect dashboard.Data for NaN/Inf floats, func/chan fields, or cycles and sanitize them before calling the API","Load the dashboard from the DB/API (already validated JSON) instead of constructing it in memory","Add a pre-check json.Marshal in your own code to get the precise offending field from the wrapped error"],"exampleFix":"// before\ndata, err := dashboardtypes.NewPublicDashboardDataFromDashboard(dash)\n\n// after\nif _, err := json.Marshal(dash.Data); err != nil {\n    return fmt.Errorf(\"dashboard data not serializable: %w\", err)\n}\ndata, err := dashboardtypes.NewPublicDashboardDataFromDashboard(dash)","handlingStrategy":"validation","validationCode":"if _, err := json.Marshal(dash.Data); err != nil {\n    return fmt.Errorf(\"dashboard data not serializable: %w\", err)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never put NaN/Inf, funcs, or cyclic structures into panel data","Load dashboards from validated storage rather than building them ad hoc"],"tags":["dashboard","json","marshal","public-dashboard"],"backgroundTag":"json-marshal-failure","analyzedSha":"5069bf80b08f1f00d7e014eccc09902f9871004f","analyzedAt":"2026-08-28T06:22:12.824Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}