-
Notifications
You must be signed in to change notification settings - Fork 177
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
"invalid character '\\x1f' looking for beginning of value" error while using 'tsm' ALB mode #599
Comments
Oh, almost forgot! I'm using |
We also ran into this with similar configuration and same versions of tricksters & prometheus. |
Seems there's some issue while merging of two JSON payloads - https://stackoverflow.com/questions/64460591/unmarshalling-json-returns-an-error-invalid-character-x1f-looking-for-beginn @jranson could you please take a look? 🙏 |
I have the same issue. at least in my case is happening because trickster is encoding the response from the backends with gzip even if it was received with no encoding. and then when it comes time to parse and merge the results, it's trying to json parse gzip-encoded data directly (hence the the response from the backend gets encoded here, but the I've "fixed" the problem for me by decoding it as needed in the diff --git a/pkg/proxy/response/merge/merge.go b/pkg/proxy/response/merge/merge.go
index 4a6ed876..ee2db1f1 100644
--- a/pkg/proxy/response/merge/merge.go
+++ b/pkg/proxy/response/merge/merge.go
@@ -17,8 +17,13 @@
package merge
import (
+ "bytes"
+ "io"
"net/http"
+ "github.com/trickstercache/trickster/v2/pkg/encoding/profile"
+ "github.com/trickstercache/trickster/v2/pkg/encoding/providers"
+ "github.com/trickstercache/trickster/v2/pkg/proxy/headers"
"github.com/trickstercache/trickster/v2/pkg/proxy/request"
"github.com/trickstercache/trickster/v2/pkg/util/copiers"
)
@@ -57,6 +62,22 @@ func (rg *ResponseGate) WriteHeader(i int) {
// Body returns the stored body for merging
func (rg *ResponseGate) Body() []byte {
+ ep := profile.Profile{
+ ContentEncoding: rg.header.Get(headers.NameContentEncoding),
+ ContentType: rg.header.Get(headers.NameContentType),
+ }
+
+ ep.ContentEncodingNum = providers.ProviderID(ep.ContentEncoding)
+
+ di := ep.GetDecoderInitializer()
+ if di != nil {
+ decoder := di(bytes.NewReader(rg.body))
+
+ data, _ := io.ReadAll(decoder)
+
+ return data
+ }
+
return rg.body
} I do not think this is the right solution to the problem though as the error's being ignored and the response to the final client does not have any Content-Encoding set. it does work to validate that the issue is about trying to parse the data without decoding it first (or saving it decoded when it should have been plain text) @jnichols-git do you know what would be the proper way to handle this? |
Hey! 👋
Got alot of errors in logs while using 'tsm' ALB mode 🙁
I assume that I misconfigure something, but I've spend a couple of days on debugging already and found nothing special in my config.
@jranson could you please assist? 🙏
Thanks!
Log:
Config:
Full config:
The text was updated successfully, but these errors were encountered: