{"record":{"id":"da362d8a87b339d0","repo":"SigNoz/signoz","slug":"invalid-input-da362d","errorCode":"invalid_input","errorMessage":"failed to decode request body","messagePattern":"failed to decode request body","errorType":"error_code","errorClass":"errors.base","httpStatus":400,"severity":"error","filePath":"pkg/modules/savedview/implsavedview/handler.go","lineNumber":154,"sourceCode":"\t\t}\n\t\tout = append(out, legacyView)\n\t}\n\treturn out, nil\n}\n\nfunc (handler *handler) Create(w http.ResponseWriter, r *http.Request) {\n\tctx, cancel := context.WithTimeout(r.Context(), 10*time.Second)\n\tdefer cancel()\n\n\tclaims, err := authtypes.ClaimsFromContext(ctx)\n\tif err != nil {\n\t\trender.Error(w, err)\n\t\treturn\n\t}\n\n\tvar view v3.SavedView\n\tif err := json.NewDecoder(r.Body).Decode(&view); err != nil {\n\t\trender.Error(w, errors.Wrapf(err, errors.TypeInvalidInput, errors.CodeInvalidInput, \"failed to decode request body\"))\n\t\treturn\n\t}\n\t// validate the query\n\tif err := view.Validate(); err != nil {\n\t\trender.Error(w, errors.Wrapf(err, errors.TypeInvalidInput, errors.CodeInvalidInput, \"failed to validate request body\"))\n\t\treturn\n\t}\n\n\tpostable := newPostableSavedViewFromLegacyView(&view)\n\n\tif err := postable.Validate(); err != nil {\n\t\trender.Error(w, err)\n\t\treturn\n\t}\n\n\tuuid, err := handler.module.CreateView(ctx, claims.OrgID, postable)\n\tif err != nil {\n\t\trender.Error(w, err)","sourceCodeStart":136,"sourceCodeEnd":172,"githubUrl":"https://github.com/SigNoz/signoz/blob/5069bf80b08f1f00d7e014eccc09902f9871004f/pkg/modules/savedview/implsavedview/handler.go#L136-L172","documentation":"The saved view Create handler could not json.Decode the request body into v3.SavedView, returning an invalid_input error. This means the body is not valid JSON at all (syntax error, empty body, wrong content) — semantic validation happens afterwards and produces a different message.","triggerScenarios":"POST to the saved-views endpoint with malformed JSON: trailing commas, single quotes, unquoted keys, an empty body, or a body already consumed/incorrectly chunked by a proxy.","commonSituations":"Hand-written curl without proper quoting, frontend sending form-encoded or pre-stringified- twice payloads, proxies stripping bodies on redirect (301/302 turning POST into GET), or a truncated request body.","solutions":["Validate the raw body with a JSON linter before sending","Ensure Content-Type: application/json and that the body is a single properly quoted JSON document (no trailing commas, double quotes for keys/strings)","Check for proxy/redirect issues that drop or alter the request body","Log/echo the exact bytes sent from the client to spot truncation"],"exampleFix":"# before\ncurl -X POST https://signoz/api/v1/saved-views -d \"{name: 'my view',}\"\n\n# after\ncurl -X POST https://signoz/api/v1/saved-views -H 'Content-Type: application/json' \\\n  -d '{\"name\": \"my view\", \"query\": {...}}'","handlingStrategy":"validation","validationCode":"const body = JSON.stringify(view); // throws client-side on bad structure\nJSON.parse(body); // round-trip sanity check\nawait fetch('/api/v1/saved-views', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body });","typeGuard":"function isSavedView(v: unknown): v is SavedView {\n  return typeof v === 'object' && v !== null && typeof (v as any).name === 'string';\n}","tryCatchPattern":"try { await createSavedView(view); } catch (e) { if (e.code === 'invalid_input' && /decode/i.test(e.message)) showFormError('Invalid JSON — check the request body'); else throw e; }","preventionTips":["Always set Content-Type: application/json and send JSON.stringify-ed bodies exactly once","Avoid trailing commas/single quotes in hand-written curl payloads","Beware proxies/redirects that drop POST bodies"],"tags":["json","request-body","invalid-input","rest-api","golang"],"backgroundTag":"malformed-json-request-body","analyzedSha":"5069bf80b08f1f00d7e014eccc09902f9871004f","analyzedAt":"2026-08-28T06:22:12.824Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}