{"record":{"id":"d2be5b239b3c7e28","repo":"SigNoz/signoz","slug":"errcodepublicdashboardinvalidinput","errorCode":"ErrCodePublicDashboardInvalidInput","errorMessage":"widget index is missing from the path","messagePattern":"widget index is missing from the path","errorType":"http","errorClass":null,"httpStatus":400,"severity":"warning","filePath":"pkg/modules/dashboard/impldashboard/handler.go","lineNumber":160,"sourceCode":"\t\treturn\n\t}\n\n\trender.Success(rw, http.StatusOK, gettablePublicDashboardData)\n}\n\nfunc (handler *handler) GetPublicWidgetQueryRange(rw http.ResponseWriter, r *http.Request) {\n\tctx, cancel := context.WithTimeout(r.Context(), 10*time.Second)\n\tdefer cancel()\n\n\tid, err := valuer.NewUUID(mux.Vars(r)[\"id\"])\n\tif err != nil {\n\t\trender.Error(rw, err)\n\t\treturn\n\t}\n\n\twidgetIndex, ok := mux.Vars(r)[\"idx\"]\n\tif !ok {\n\t\trender.Error(rw, errors.New(errors.TypeInvalidInput, dashboardtypes.ErrCodePublicDashboardInvalidInput, \"widget index is missing from the path\"))\n\t\treturn\n\t}\n\n\tdashboard, err := handler.module.GetDashboardByPublicID(ctx, id)\n\tif err != nil {\n\t\trender.Error(rw, err)\n\t\treturn\n\t}\n\n\tpublicDashboard, err := handler.module.GetPublic(ctx, dashboard.OrgID, valuer.MustNewUUID(dashboard.ID))\n\tif err != nil {\n\t\trender.Error(rw, err)\n\t\treturn\n\t}\n\n\twidgetIdx, err := strconv.ParseUint(widgetIndex, 10, 64)\n\tif err != nil {\n\t\trender.Error(rw, errors.New(errors.TypeInvalidInput, dashboardtypes.ErrCodePublicDashboardInvalidInput, \"invalid widget index\"))","sourceCodeStart":142,"sourceCodeEnd":178,"githubUrl":"https://github.com/SigNoz/signoz/blob/5069bf80b08f1f00d7e014eccc09902f9871004f/pkg/modules/dashboard/impldashboard/handler.go#L142-L178","documentation":"The public dashboard widget query-range handler requires a widget index path variable ({idx}) in the route. When the mux route match does not include the 'idx' variable, the handler rejects the request with ErrCodePublicDashboardInvalidInput.","triggerScenarios":"Issuing GET on a public dashboard widget metrics URL where the {idx} path segment is absent or the route was registered without the {idx} placeholder, so mux.Vars(r)['idx'] is missing.","commonSituations":"Route registered as /api/v1/query_range instead of /api/v1/{idx}/query_range; client building the URL without appending the widget index; reverse proxy or router rewrite stripping the path segment.","solutions":["Include the widget index segment in the request URL (e.g. /public/{id}/3/query_range)","Verify the route pattern contains {idx}","Check gateway/ingress rewrite rules are not dropping the path segment"],"exampleFix":"// before\nGET /api/v1/dashboards/{publicID}/query_range\n\n// after\nGET /api/v1/dashboards/{publicID}/3/query_range","handlingStrategy":"validation","validationCode":"const idxRe = /^\\d+$/;\nfunction buildWidgetURL(publicId, idx) {\n  if (idx === undefined || idx === null || !idxRe.test(String(idx))) {\n    throw new Error('widget index required');\n  }\n  return `/api/v1/dashboards/${publicId}/${idx}/query_range`;\n}","typeGuard":"function isValidWidgetIndex(idx) {\n  return typeof idx === 'number' && Number.isInteger(idx) && idx >= 0;\n}","tryCatchPattern":"try { const res = await fetch(url); } catch (e) { /* network */ }\nif (res.status === 400 && body.code === 'public_dashboard_invalid_input') { /* rebuild URL with idx */ }","preventionTips":["Centralize public dashboard URL construction in one helper","Add integration tests asserting the {idx} route segment"],"tags":["dashboard","public-dashboard","routing","validation"],"backgroundTag":"missing-path-parameter","analyzedSha":"5069bf80b08f1f00d7e014eccc09902f9871004f","analyzedAt":"2026-08-28T06:22:12.824Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}