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

Can't search repos with underscore in repo name #1406

Closed
dsplaisted opened this issue Jun 24, 2016 · 1 comment · Fixed by #1418
Closed

Can't search repos with underscore in repo name #1406

dsplaisted opened this issue Jun 24, 2016 · 1 comment · Fixed by #1418

Comments

@dsplaisted
Copy link
Contributor

The following test fails:

    [IntegrationTest]
    public async Task SearchForFileNameInCodeWithoutTermWithUnderscore()
    {
        var request = new SearchCodeRequest()
        {
            FileName = "readme.md",
            Repos = new RepositoryCollection { "Cultural-Rogue/_51Wp.XinFengSDK.Demo" }
        };

        var repos = await _gitHubClient.Search.SearchCode(request);
    }

It fails with the following exception:

Octokit.RepositoryFormatException : The list of repositories must be formatted as 'owner/name' - these values don't match this rule: Cultural-Rogue/_51Wp.XinFengSDK.Demo
at Octokit.SearchCodeRequest.MergedQualifiers() in C:\git\octokit.net\Octokit\Models\Request\SearchCodeRequest.cs:line 204
   at Octokit.BaseSearchRequest.get_TermAndQualifiers() in C:\git\octokit.net\Octokit\Models\Request\BaseSearchRequest.cs:line 87
   at Octokit.BaseSearchRequest.get_Parameters() in C:\git\octokit.net\Octokit\Models\Request\BaseSearchRequest.cs:line 106
   at Octokit.SearchClient.SearchCode(SearchCodeRequest search) in C:\git\octokit.net\Octokit\Clients\SearchClient.cs:line 67
   at SearchClientTests.<SearchForFileNameInCodeWithoutTermWithUnderscore>d__8.MoveNext() in C:\git\octokit.net\Octokit.Tests.Integration\Clients\SearchClientTests.cs:line 99
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)

The culprit seems to be this Regex. With a quick search I couldn't find documentation on what the allowed formats for GitHub usernames and repo names are, so I don't know if adding an underscore to the Regex is all that's needed or if there are other possibilities. Perhaps there's no need to do client-side validation of this at all.

dsplaisted added a commit to dsplaisted/octokit.net that referenced this issue Jun 24, 2016
@shiftkey
Copy link
Member

@dsplaisted 👍 to relaxing the regex to include _- I did a quick test of other special characters and the only one I could find permitted is a -

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

Successfully merging a pull request may close this issue.

2 participants