SigNoz/signoz · error · model.ApiError
couldn't JSON decode existingFilter: %w
Error message
couldn't JSON decode existingFilter: %w
What it means
After successfully base64-decoding 'existingFilter', the bytes must be valid JSON matching v3.FilterSet. This error means decoding succeeded but json.Unmarshal failed.
Source
Thrown at pkg/query-service/app/parser.go:570
baseconstants.DefaultFilterSuggestionsExamplesLimit,
baseconstants.MaxFilterSuggestionsExamplesLimit,
)
if err != nil {
return nil, err
}
var existingFilter *v3.FilterSet
existingFilterB64 := r.URL.Query().Get("existingFilter")
if len(existingFilterB64) > 0 {
decodedFilterJson, err := base64.RawURLEncoding.DecodeString(existingFilterB64)
if err != nil {
return nil, model.BadRequest(fmt.Errorf("couldn't base64 decode existingFilter: %w", err))
}
existingFilter = &v3.FilterSet{}
err = json.Unmarshal(decodedFilterJson, existingFilter)
if err != nil {
return nil, model.BadRequest(fmt.Errorf("couldn't JSON decode existingFilter: %w", err))
}
}
searchText := r.URL.Query().Get("searchText")
return &v3.QBFilterSuggestionsRequest{
DataSource: dataSource,
SearchText: searchText,
ExistingFilter: existingFilter,
AttributesLimit: attributesLimit,
ExamplesLimit: examplesLimit,
}, nil
}
func parseFilterAttributeKeyRequest(r *http.Request) (*v3.FilterAttributeKeyRequest, error) {
var req v3.FilterAttributeKeyRequest
dataSource := v3.DataSource(r.URL.Query().Get("dataSource"))View on GitHub (pinned to 5069bf80b0)
Solutions
- Validate the JSON locally against the FilterSet schema (operator string, items array of filter items) before encoding
- Print the decoded bytes and run them through a JSON validator
- Ensure you encoded the final JSON once, not twice
Example fix
// before
enc := base64.RawURLEncoding.EncodeToString([]byte(`{"items": "foo"}`))
// after
enc := base64.RawURLEncoding.EncodeToString([]byte(`{"operator":"AND","items":[]}`)) Defensive patterns
Strategy: try-catch
Validate before calling
decoded, _ := base64.RawURLEncoding.DecodeString(b64)
var fs v3.FilterSet
if err := json.Unmarshal(decoded, &fs); err != nil { return fmt.Errorf("existingFilter is not valid FilterSet JSON") } Type guard
func isValidFilterSetJSON(b []byte) bool { var fs v3.FilterSet; return json.Unmarshal(b, &fs) == nil } Try / catch
Catch the 400 response, decode the message, and surface which stage (base64 vs JSON) failed to the user for correction.
Prevention
- Validate FilterSet shape before encoding
- Keep client FilterSet types generated from the server schema
When it happens
Trigger: existingFilter decodes to non-JSON bytes, or JSON with wrong types (e.g. items as a string instead of array, operator misspelled structure).
Common situations: Encoding a partial/mocked object; schema drift between the client's FilterSet shape and the server's v3.FilterSet; double-encoding so the outer decode yields base64 text.
Related errors
- invalid request body: %v
- error decoding request: %v
- couldn't base64 decode existingFilter: %w
- cannot parse the request body: %v
- CodeLicenseUnavailable
AI-assisted analysis of SigNoz/signoz@5069bf80b0 (2026-08-28).
Data as JSON: /api/errors/b8d8503529989f8e.
Report an issue: GitHub.