Sentry: vsts: UnsupportedResponseType: text/html; charset=utf-8

Created on 25 Sep 2017  路  34Comments  路  Source: getsentry/sentry

https://sentry.io/share/issue/312e333535313939393137/

UnsupportedResponseType: text/html; charset=utf-8
  File "sentry_plugins/client.py", line 56, in from_response
    raise UnsupportedResponseType(response.headers['Content-Type'], response.status_code)
  File "sentry_plugins/client.py", line 140, in _request
    return BaseApiResponse.from_response(resp)
  File "sentry_plugins/client.py", line 205, in _request
    *args, **kwargs)
  File "sentry_plugins/vsts/client.py", line 26, in request
    return self._request(method, path, headers=headers, data=data, params=params)
  File "sentry_plugins/client.py", line 153, in patch
    return self.request('PATCH', *args, **kwargs)
...
(3 additional frame(s) were not displayed)

text/html; charset=utf-8

All 34 comments

I've still yet to determine exactly why its unhappy about this, as we seem to be doing everything correctly per the docs. Google'ing for this hasn't yield much help other than people having this issue on some microsoft services, which could simply be related to the webserver they use.

Struggling to repro again locally, but fixed a couple of more items here:

https://github.com/getsentry/sentry-plugins/pull/251

And improving the response handling (at least our assumptions) here:

https://github.com/getsentry/sentry-plugins/pull/250

I was seeing if there was anything I could potentially help with from my side. I thought I'd check the URL formats you are hitting (Projects and Work Items) and they both return valid data for my instance.

That's when I noticed a "my bad". As a typical user, I didn't read/understand the labels and entered this:

image

... where you were probably expecting this:

image

Using instance.visualstudio.com produces the text/html; charset=utf-8 error. Using just instance produces a different error:

An internal error occurred with the integration and the Sentry team has been notified


As a suggestion, perhaps the integration could do some form validation and prevent strings ending in .visualstudio.com.

It's actually expecting 'example.visualstudio.com'. If you put 'instance', then we would query 'https://instance/'.

Ah, good to know that I was right first time ;) Sorry about the diversion...

Just to share one other thing, VSTS allows you to query the Web API for projects by name or GUID. I tried changing the Sentry integration to use the project GUID but it didn't work.

@stajs So I've pushed out a few various improvements. I dont think its going to resolve anything, but can you try again and let me know if you're seeing this issue?

Still, got the charset error when linking. Is the Work Item ID expecting an integer? I'll re-add the identity to see if that affects anything...

Re-adding the identity didn't help.

Yeah linking is the issue # which is an integer. Will try to find someone at visual studio to help us figure out what鈥檚 going on at this point. I don鈥檛 actually even know how to reproduce it anymore, but I definitely hit this in some cases early in development.

Not ideal I know, but feel free to ping me if you want me to reproduce it.

You guys have got way more detail than I do, but perhaps I can throw out some thoughts to try reverse-rubber ducking. I'm definitely not attempting to teach you how to suck eggs here!

  • What's the content/headers of the response? When I first saw HTML content, I thought VSTS might be throwing up a sign-in page, but it's not a 401.
  • A 203 suggests a proxy server has transformed the content. I don't suppose you have a proxy on your side fiddling with things? Can you un-transform it?
  • Is it actually unauthorized? This guy got a 203 with a sign-in page.
  • You are using OAuth, right? Access token hasn't expired (or nearly expired)? Docs say they "expire relatively quickly", how long do they last? Perhaps a call to refresh the token, right before the actual API call? You mentioned this is errorring on the refresh, so might not be relevant.
  • Can you test with a Personal Access Token instead? It might help prove it is an OAuth problem.
  • I assume this works for other VSTS users. I wouldn't be surprised if there was something unusual with the way our company has set up VSTS. I could potentially try and set up a personal VSTS account to test.

@stajs

  • I also assumed it was a signup page. I will try to grab the output when I get a moment, but it was some page saying 'the browser doesnt support blah blah'
  • No proxies anywhere on our side.
  • I'm not sure its unauthorized, but I'm pretty confident that when I refreshed a token previously it resolved the 203 page.
  • We automatically fetch a new access token when the refresh token has expired
  • Even if the personal access token works, it doesnt really help our situation, so unlikely to invest any effort there
  • I doubt its related to your company, but hoping the VSTS team can shed more light. Again we saw it on our test account at least at one point.

Received a note to make sure we're using the application/json-patch+json. I mistakenly thought we had deployed the latest changes to sentry-plugins, and it turns out that we had an issue in our system that automatically bumps these revisions and it never happened. I'm going to get that out today.

@stajs mind giving it a shot now?

New problem:

You need to associate an identity with undefined before you can create issues with this service.

image

Before doing anything else, I double checked that I had an identity and I did:

image

I disconnected it, and then tried to Associate Identity under the error message (first screenshot). I followed the flow to VSTS and back to Sentry and confirmed that the Identity was showing up again under My Settings > Identities. I tried to Link with Existing Issue again but the new problem still shows.

@stajs to confirm, you're just getting a "Not Authenticated" problem?

Sorry, not understanding the question. I don't see any authentication problems...

If you mean with the Identity flow to VSTS, I can screenshot the flow:

  1. Disconnect the Visual Studio identity:
    image
    image
  2. Link:
    image
  3. Associate identity:
    image
    image
    image
  4. Confirm identity:
    image
  5. Try linking again:
    image
  6. New problem:
    image

The request to https://sentry.io/api/0/issues/{id}/plugins/vsts/link/ responds with a 400 Bad request:

{"error_type": "auth", "auth_url": "/account/settings/social/associate/visualstudio/"}

@stajs k so sounds like its still having the same issue. I'm going to rip out this 'handle the 203 like an unauthenticated request' code, as its clearly not correct.

What's the undefined part of the error message supposed to be?

@stajs Im also looking into that, but its simply an error message being reported incorrectly

@stajs can you confirm things are still problematic? I believe we might have 'fixed' the 203 error (it shouldnt show up anymore, at least to my understanding).

Sorry for the trouble. This would be a lot easier if we could repro it ourselves.

I can confirm: still problematic with text/html; charset=utf-8 error.

@stajs could you drop me an email with your account username (thats authenticated with VSTS) on sentry.io? (david at sentry.io). I'm going to try to debug what the exact error we're receiving is here.

Email sent.

@stajs I didn't see it come through.Mind trying again? You can also send it to dcramer at gmail

OK, tried your Gmail...

We've got a full response fixture now to work with thanks to @stajs.

For record keeping, the response is a 203 that resembles a login page

Visual Studio Team Services | Sign In

A smoking 馃敨 ...!

Ok it looks like our API client redirects by default, and the API endpoint is returning a 302.

I've redacted details, but the redirect looks like this:

https://app.vssps.visualstudio.com/_signin?realm=INSTANCE&reply_to=API_URL&redirect=1&force=1&context=CONTEXT#ctx=CONTEXT

Context seems to be base64 encoded, and isnt sensitive:

>>> base64.b64decode('eyJTaWduSW5Db29raWVEb21haW5zIjpbImh0dHBzOi8vbG9naW4ubWljcm9zb2Z0b25saW5lLmNvbSIsImh0dHBzOi8vbG9naW4ubWljcm9zb2Z0b25saW5lLmNvbSJdfQ2==')
'{"SignInCookieDomains":["https://login.microsoftonline.com","https://login.microsoftonline.com"]}\r'

Sorry, not understanding the question. I don't see any authentication problems...

If you mean with the Identity flow to VSTS, I can screenshot the flow:

1. Disconnect the Visual Studio identity:
   ![image](https://user-images.githubusercontent.com/2253814/31100663-d8c0f8a6-a826-11e7-9001-2eb0d955db50.png)
   ![image](https://user-images.githubusercontent.com/2253814/31100689-f3ad54fc-a826-11e7-972f-d8690525e822.png)

2. Link:
   ![image](https://user-images.githubusercontent.com/2253814/31100718-0d91632c-a827-11e7-985a-ec177dac7190.png)

3. Associate identity:
   ![image](https://user-images.githubusercontent.com/2253814/31100744-291f3858-a827-11e7-8d6f-191b479e0045.png)
   ![image](https://user-images.githubusercontent.com/2253814/31100779-47d8694a-a827-11e7-961c-6fe73e0ce223.png)
   ![image](https://user-images.githubusercontent.com/2253814/31100803-5e9a81ae-a827-11e7-9b61-e03e12fb73d6.png)

4. Confirm identity:
   ![image](https://user-images.githubusercontent.com/2253814/31100835-7fd0d706-a827-11e7-80e0-836831742bdd.png)

5. Try linking again:
   ![image](https://user-images.githubusercontent.com/2253814/31100855-90ae1e9e-a827-11e7-89b5-3729d2d97984.png)

6. New problem:
   ![image](https://user-images.githubusercontent.com/2253814/31100903-b8b22e08-a827-11e7-95bb-9379f6640c5c.png)

The request to https://sentry.io/api/0/issues/{id}/plugins/vsts/link/ responds with a 400 Bad request:

{"error_type": "auth", "auth_url": "/account/settings/social/associate/visualstudio/"}

I have the same problem with on-premise installation on Kubernetes, couldn't figure it out whatever I tried. Since this issue is still open, I guess there is no fix for it yet?

The old vsts plugin is now deprecated in favor of the new integration. They said I鈥檓 pretty sure these problems are resolved but likely not in whichever version of sentry you鈥檙e running.

The old vsts plugin is now deprecated in favor of the new integration. They said I鈥檓 pretty sure these problems are resolved but likely not in whichever version of sentry you鈥檙e running.

I am using the official docker image which is released 4 days ago.

@iboware im pretty sure thats not the current version of Sentry unless its actually building from source (which most people don't do)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

dcramer picture dcramer  路  4Comments

codekitchen picture codekitchen  路  3Comments

Leroygirl picture Leroygirl  路  3Comments

benvinegar picture benvinegar  路  4Comments

phiresky picture phiresky  路  3Comments