Repository navigation
Send a valid User-Agent when the app name is not an HTTP token [patch] - #200
Merged
Merged
Conversation
GitHubProvider built Octokit's ProductHeaderValue straight from AppDomain.FriendlyName, so a host built from "My App.csproj" threw FormatException from every call before a request was sent, outside the GitHostingException hierarchy. Replace characters outside the RFC 9110 token set with '-', fall back to "ktsu.GitIntegration" when nothing usable is left, and test it through the fake transport with names the test host itself never has. Fixes #195 Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_016n29aex51pHZeVj2vx831E
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Fixes #195
What changed
GitHubProvider.CreateClient()passedAppDomain.CurrentDomain.FriendlyNamestraight to Octokit'sProductHeaderValue. If the host's entry assembly name isn't an HTTP token (for exampleMy ApporTool (x86)), everyGitHubProvidercall threwFormatExceptionbefore sending a request, and the exception escaped theGitHostingExceptionhierarchy.GitIntegration/GitHubProvider.cs:ToProductName(string?). It replaces every character outside the RFC 9110 token set, including non-ASCII letters, with-and trims leading and trailing dashes. If nothing usable is left, it falls back toktsu.GitIntegration. The host's name still shows in GitHub's logs whenever any of it is usable.ApplicationNameinit property, defaulting toFriendlyName. It lets tests drive names the test host never has; under MSTest the host's name is alwaystesthost.GitIntegration.Test/Hosting/GitHubProviderTests.cs:GetRepositoriesAsyncthroughFakeHttpMessageHandlerwithMy App,Tool (x86),a/b@c,Café,testhostandktsu.Tool_1. It asserts that the request is sent and checks the product name in the User-Agent.AzureDevOpsProvidersets no User-Agent from the app name, so only the GitHub provider needed the change.Verification
new(ApplicationName)), the four non-token cases fail with the exception from the issue:System.FormatException: The format of value 'My App' is invalid.With the fix, they pass.net10.0andnet9.0has 0 warnings and 0 errors.🤖 Generated with Claude Code
https://claude.ai/code/session_016n29aex51pHZeVj2vx831E
Generated by Claude Code