-
Notifications
You must be signed in to change notification settings - Fork 122
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
Stepping into code brings up "The request returned an unexpected mime type (text/html)" with Gitea #1086
Comments
@K-Dambeck I am unfamiliar with Gitea. Are you using a cloud hosted service? Or something that you have installed and manage yourself? (or is installed/managed by your organization?) |
It is installed and managed by our company, yes. It's effectively a git server but with a few extra features from what I can tell (I'm also still new to using it) |
Hey, just wanted to ask if there's any progress on this (not trying to rush anyone) |
What version of Visual Studio are you using? IIRC older versions outright refused to authenticate for Source Link to anything other than Azure DevOps domains. |
We're on Visual Studio 2022 17.6 which should be the most recent patch |
@K-Dambeck one thing to try would be to enable Debug > Options > General > Fall back to Git Credential Manager authentication for all Source Link requests. If that does not work, a fiddler trace of VS while attempting to obtain a file from Gitea via Source Link would be helpful. As this is a VS issue, you can report it at https://developercommunity.visualstudio.com/ and then you'll be able to securely upload files that I can access. It depends what kind of authentication mechanisms are available to Gitea. As an example, what happens when you clone the repo? How do you authenticate? |
Hey, sorry for the radio silence. Apart from just logging in with a password, there's two-factor authentication, in my case using Google Authenticator, though I believe there are also other methods. |
If you have a private repository, gitea will just happily redirect the URL to the login page. Hence the text/html. What you'Il want to do is somehow match the source link request and nudge it the right way. In IIS URL rewrite you can do it like this: <rule name="Rewrite SourceLink Urls with Authorization" stopProcessing="true">
<match url="^([A-z0-9_\-.]+)/([A-z0-9_\-.]+)/raw/commit/([A-f0-9]+)/(.+)" />
<conditions>
<add input="{HTTP_USER_AGENT}" pattern="Microsoft-Symbol-Server" />
<add input="{HTTP_AUTHORIZATION}" pattern="^Token\s(.+)" />
</conditions>
<action type="Rewrite" url="http://127.0.0.1:8099/api/v1/repos/{R:1}/{R:2}/media/{URLEncode:{R:4}}?ref={R:3}&token={C:1}" logRewrittenUrl="true" appendQueryString="true" />
</rule>
<rule name="Rewrite SourceLink Urls" stopProcessing="true">
<match url="^([A-z0-9_\-.]+)/([A-z0-9_\-.]+)/raw/commit/([A-f0-9]+)/(.+)" />
<conditions>
<add input="{HTTP_USER_AGENT}" pattern="Microsoft-Symbol-Server" />
</conditions>
<action type="Rewrite" url="http://127.0.0.1:8099/api/v1/repos/{R:1}/{R:2}/media/{URLEncode:{R:4}}?ref={R:3}" logRewrittenUrl="true" appendQueryString="true" />
</rule> The second rule will match unauthorized requests and if the repo is public or anonymous access is enabled it will return a response, else it will return a 403. This 403 will nudge Visual Studio or Resharper that auth is required. If you then pass in a gitea api key, the next requests will be authorized. These requests will match the first rule, and then nicely request the file via the Gitea api. |
Hi,
while in Visual Studio using the debug feature "step into" on a piece of code, it's supposed to look for the program that includes the parent class on my hard drive, and if it doesn't find it there, it's supposed to look for it using source link.
In the source search information, I see that it is in fact searching my computer, but once it gets to trying to find it via source link, I receive the following log entries:
Looking for source using Source Link ([URL to the file on the git server])...
Source Link errors:
ERROR: The request returned an unexpected mime type (text/html).
The file was not found with Source Link.
When checking the url, it is correct, though I have to first log in to see the actual .cs file that is being searched. From what I can tell, I believe the source link gets to that same log-in screen but then either can't find the credentials to log in, or something along those lines.
Any help is appreciated!
The text was updated successfully, but these errors were encountered: