{"record":{"id":"dede1ec6df0be0c1","repo":"SigNoz/signoz","slug":"code-invalid-input","errorCode":"CODE_INVALID_INPUT","errorMessage":"invalid filter JSON","messagePattern":"invalid filter JSON","errorType":"validation","errorClass":null,"httpStatus":400,"severity":"error","filePath":"pkg/types/quickfiltertypes/filter.go","lineNumber":94,"sourceCode":"\ntype UpdatableQuickFilters struct {\n\tSignal  Signal            `json:\"signal\"`\n\tFilters []v3.AttributeKey `json:\"filters\"`\n}\n\n// NewStorableQuickFilter creates a new StorableQuickFilter after validation.\nfunc NewStorableQuickFilter(orgID valuer.UUID, signal Signal, filterJSON []byte) (*StorableQuickFilter, error) {\n\tif orgID.StringValue() == \"\" {\n\t\treturn nil, errors.Newf(errors.TypeInvalidInput, errors.CodeInvalidInput, \"orgID is required\")\n\t}\n\n\tif _, err := NewSignal(signal.StringValue()); err != nil {\n\t\treturn nil, err\n\t}\n\n\tvar filters []v3.AttributeKey\n\tif err := json.Unmarshal(filterJSON, &filters); err != nil {\n\t\treturn nil, errors.Wrapf(err, errors.TypeInvalidInput, errors.CodeInvalidInput, \"invalid filter JSON\")\n\t}\n\n\tnow := time.Now()\n\treturn &StorableQuickFilter{\n\t\tIdentifiable: types.Identifiable{\n\t\t\tID: valuer.GenerateUUID(),\n\t\t},\n\t\tOrgID:  orgID,\n\t\tSignal: signal,\n\t\tFilter: string(filterJSON),\n\t\tTimeAuditable: types.TimeAuditable{\n\t\t\tCreatedAt: now,\n\t\t\tUpdatedAt: now,\n\t\t},\n\t}, nil\n}\n\n// Update updates an existing StorableQuickFilter with new filter data after validation.","sourceCodeStart":76,"sourceCodeEnd":112,"githubUrl":"https://github.com/SigNoz/signoz/blob/5069bf80b08f1f00d7e014eccc09902f9871004f/pkg/types/quickfiltertypes/filter.go#L76-L112","documentation":"NewStorableQuickFilter validates and stores a quick filter: it checks the signal value and then json.Unmarshals the filterJSON bytes into []v3.AttributeKey. If the JSON is malformed or its elements don't match the AttributeKey schema, it returns CODE_INVALID_INPUT 'invalid filter JSON'.","triggerScenarios":"POST/PUT to the quick-filters API (UpdateQuickFilters) where the filter payload is invalid JSON, a JSON object instead of an array, or array elements missing/wrong-typed fields for v3.AttributeKey (key, dataType, isColumn...).","commonSituations":"Frontend sending the filter object directly instead of wrapping it in an array; truncation of large filter payloads by proxies; mismatched AttributeKey field names after a v3 API schema change.","solutions":["Ensure the body is a JSON array of AttributeKey objects: [{\"key\":\"service.name\",\"dataType\":\"string\",...}]","Validate client-side with the same struct before sending","Check gateway/proxy request-size limits if large filters get truncated"],"exampleFix":"// before\nfilterJSON := []byte(`{\"key\":\"service.name\",\"dataType\":\"string\"}`)\n\n// after\nfilterJSON := []byte(`[{\"key\":\"service.name\",\"dataType\":\"string\",\"isColumn\":true}]`)","handlingStrategy":"validation","validationCode":"var attrs []v3.AttributeKey\nif err := json.Unmarshal(filterJSON, &attrs); err != nil || len(attrs) == 0 {\n    return errors.New(\"filters must be a non-empty JSON array of AttributeKey\")\n}","typeGuard":"func isValidFilterJSON(b []byte) bool {\n    var attrs []v3.AttributeKey\n    return json.Unmarshal(b, &attrs) == nil\n}","tryCatchPattern":null,"preventionTips":["Wrap single filters in an array client-side","Validate against the v3.AttributeKey schema before POSTing"],"tags":["json","quick-filter","validation","attributekey"],"backgroundTag":"invalid-json-payload","analyzedSha":"5069bf80b08f1f00d7e014eccc09902f9871004f","analyzedAt":"2026-08-28T06:22:12.824Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}