SigNoz/signoz · error · model.ApiError
couldn't base64 decode existingFilter: %w
Error message
couldn't base64 decode existingFilter: %w
What it means
parseQBFilterSuggestionsRequest accepts an optional 'existingFilter' query param that must be base64 (RawURL encoding) of a JSON FilterSet. This error means the base64 decode step itself failed.
Source
Thrown at pkg/query-service/app/parser.go:564
if err != nil {
return nil, err
}
examplesLimit, err := parsePositiveIntQP(
"examplesLimit",
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,
}, nilView on GitHub (pinned to 5069bf80b0)
Solutions
- Encode with base64.RawURLEncoding (URL-safe, no padding) in Go, or base64url without padding elsewhere
- Verify the value wasn't truncated or re-encoded by a proxy
- If passing literal JSON, remove the param and send via body if the API version supports it
Example fix
// before
?existingFilter={"operator":"AND","items":[]}
// after (Go)
enc := base64.RawURLEncoding.EncodeToString([]byte(filterJSON))
// use ?existingFilter=<enc> Defensive patterns
Strategy: validation
Validate before calling
if _, err := base64.RawURLEncoding.DecodeString(existingFilterB64); err != nil { return fmt.Errorf("existingFilter must be base64url without padding") } Type guard
func isRawURLBase64(s string) bool { _, err := base64.RawURLEncoding.DecodeString(s); return err == nil } Prevention
- Always encode with base64.RawURLEncoding in Go
- Add an integration test that round-trips encode→decode of the filter
When it happens
Trigger: Calling the query-builder suggestions endpoint with existingFilter set to a raw JSON string, standard base64 with padding, or corrupted/truncated base64.
Common situations: Sending JSON directly without encoding; using base64.StdEncoding with +/= characters instead of URL-safe no-padding encoding; string truncation from URL length limits.
Related errors
- couldn't JSON decode existingFilter: %w
- CodeLicenseUnavailable
- CodeInvalidInput
- CodeForbidden
- CodeNotFound
AI-assisted analysis of SigNoz/signoz@5069bf80b0 (2026-08-28).
Data as JSON: /api/errors/8eef0d9fe1c59048.
Report an issue: GitHub.