SigNoz/signoz · error · errors.base
invalid_input
invalid_input
Error message
failed to decode request body
What it means
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.
Source
Thrown at pkg/modules/savedview/implsavedview/handler.go:154
}
out = append(out, legacyView)
}
return out, nil
}
func (handler *handler) Create(w http.ResponseWriter, r *http.Request) {
ctx, cancel := context.WithTimeout(r.Context(), 10*time.Second)
defer cancel()
claims, err := authtypes.ClaimsFromContext(ctx)
if err != nil {
render.Error(w, err)
return
}
var view v3.SavedView
if err := json.NewDecoder(r.Body).Decode(&view); err != nil {
render.Error(w, errors.Wrapf(err, errors.TypeInvalidInput, errors.CodeInvalidInput, "failed to decode request body"))
return
}
// validate the query
if err := view.Validate(); err != nil {
render.Error(w, errors.Wrapf(err, errors.TypeInvalidInput, errors.CodeInvalidInput, "failed to validate request body"))
return
}
postable := newPostableSavedViewFromLegacyView(&view)
if err := postable.Validate(); err != nil {
render.Error(w, err)
return
}
uuid, err := handler.module.CreateView(ctx, claims.OrgID, postable)
if err != nil {
render.Error(w, err)View on GitHub (pinned to 5069bf80b0)
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
Example fix
# before
curl -X POST https://signoz/api/v1/saved-views -d "{name: 'my view',}"
# after
curl -X POST https://signoz/api/v1/saved-views -H 'Content-Type: application/json' \
-d '{"name": "my view", "query": {...}}' Defensive patterns
Strategy: validation
Validate before calling
const body = JSON.stringify(view); // throws client-side on bad structure
JSON.parse(body); // round-trip sanity check
await fetch('/api/v1/saved-views', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body }); Type guard
function isSavedView(v: unknown): v is SavedView {
return typeof v === 'object' && v !== null && typeof (v as any).name === 'string';
} Try / catch
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; } Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
Related errors
AI-assisted analysis of SigNoz/signoz@5069bf80b0 (2026-08-28).
Data as JSON: /api/errors/da362d8a87b339d0.
Report an issue: GitHub.