Skip to content
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 continuation byte #6

Open
kiedtl opened this issue Jan 5, 2019 · 9 comments
Open

invalid continuation byte #6

kiedtl opened this issue Jan 5, 2019 · 9 comments

Comments

@kiedtl
Copy link

kiedtl commented Jan 5, 2019

When I used the sample code on your README, Invoke-RestMethod fails with the following error:

Invoke-RestMethod : {"error":"Bad data decoding request (UnicodeDecodeError, 'utf8'
codec can't decode byte 0xd7 in position 124746: invalid continuation byte)"}
At C:\Users\blah\mouse\lib\ravenclient.ps1:63 char:9
+         Invoke-RestMethod -Uri $this.storeUri -Method Post -Body $jso ...
+         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (System.Net.HttpWebRequest:HttpWebR
   equest) [Invoke-RestMethod], WebException
    + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Co
   mmands.InvokeRestMethodCommand
@kiedtl kiedtl closed this as completed Jan 5, 2019
@imakiro
Copy link

imakiro commented Mar 15, 2019

I have the same error, why did you close it / how did you solve this?
for example, just using an unknown function crashes the thing...

Import-Module RavenPowerShell
$ravenClient = New-RavenClient -SentryDsn 'https://$DNSURL'
try {
plop
} catch {
$ravenClient.CaptureException($_)
}

gets me this :

Invoke-RestMethod : {"error":"Bad data decoding request (UnicodeDecodeError, 'utf8' codec can't decode byte 0xab in position 29: invalid start byte)"}
Au caractère C:\Program Files\WindowsPowerShell\Modules\RavenPowerShell\1.1\RavenPowerShell.psm1:63 : 9
+         Invoke-RestMethod -Uri $this.storeUri -Method Post -Body $jso ...
+         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation : (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebException
    + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand

@kiedtl kiedtl reopened this Mar 15, 2019
@kiedtl
Copy link
Author

kiedtl commented Mar 15, 2019

Yes - I managed to fix it after a few days of tearing out my hair.

@kiedtl
Copy link
Author

kiedtl commented Mar 15, 2019

Problem

I found it was all because I was using Oh-My-Posh. OMP stores special characters as global values. RavenPosh will blindly upload all global values to Sentry. Sentry, which appears to be written in Python, can't handle these Unicode characters and thus throws an error.

Fix

I fixed this by manually deciding what data to upload and what not to.
You can see the fixed version here. Its terribly messy, but it still works.

@imakiro
Copy link

imakiro commented Mar 15, 2019

Wow, I think we had the same symptoms and it was supposed to be a simple utf-8 encoding issue, have a look at the mentioned pull-request

@GreenBlood
Copy link

I with @imakiro managed to get it working simply :
We managed to fix it, adding "charset=utf-8" in the content-type argument. line 63 of RavenPowerShell.psm1 cf : #7

@kiedtl
Copy link
Author

kiedtl commented Mar 15, 2019

Amazing! I'll switch to your fork, but unfortunately it still doesn't work. Many programs I use with PowerShell are very fond of adding hundreds of global values, and when I try to capture the exception Sentry complains that the data being pushed is to large.

@imakiro
Copy link

imakiro commented Mar 15, 2019

Well, that's a whole new world of issues, but I think that this might be configurable in the sentry server configuration.

@kiedtl
Copy link
Author

kiedtl commented Mar 15, 2019

Doesn't look like that's possible.
Anyway, we're off topic here. I suppose we can close this issue now? or close it only when the PR is merged?

@imakiro
Copy link

imakiro commented Mar 15, 2019

I think we should wait for the merge request to be accepted

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants