Skip to content

Fix author parsing in GitHub URLs with path-based author filters#282

Open
Copilot wants to merge 3 commits into
mainfrom
copilot/fix-author-label-query-issue
Open

Fix author parsing in GitHub URLs with path-based author filters#282
Copilot wants to merge 3 commits into
mainfrom
copilot/fix-author-label-query-issue

Conversation

Copilot AI commented Oct 29, 2025

Copy link
Copy Markdown
Contributor

URLs like https://github.com/microsoft/devhome/pulls/lauren-ciha were not extracting the author filter, causing all open PRs to display instead of filtering by the specified author.

Changes

  • SearchHelper.cs: Extract 4th path segment as author when parsing owner/repo/issues/author and owner/repo/pulls/author URL patterns. Added validation to skip empty/whitespace values.

  • SearchHelperTests.cs: Added test coverage for author path segment in both pulls and issues URLs.

Example

// Before
ParseSearchStringFromUri("https://github.com/microsoft/devhome/pulls/lauren-ciha")
// => "repo:microsoft/devhome is:pr is:open"

// After
ParseSearchStringFromUri("https://github.com/microsoft/devhome/pulls/lauren-ciha")
// => "repo:microsoft/devhome is:pr is:open author:lauren-ciha"
Original prompt

This section details on the original issue you should resolve

<issue_title>Author label in query URL is not parsed properly</issue_title>
<issue_description>To repro:

Expected:

  • An empty list/"No items found"
  • Search string would be "repo:microsoft/devhome is:open is:issue author:lauren-ciha" (each filter can be in any order)

Actual:

  • The open PRs for the Dev Home repo (four at the writing of this issue)
  • Verify that the search string doesn't include "author:lauren-ciha"</issue_description>

<agent_instructions>Resolve this issue. First, write a test to confirm the bug is present in the codebase. Then, update the code as needed to make the test pass.</agent_instructions>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI self-assigned this Oct 29, 2025
Copilot AI and others added 2 commits October 29, 2025 01:51
Co-authored-by: lauren-ciha <64796985+lauren-ciha@users.noreply.github.com>
Co-authored-by: lauren-ciha <64796985+lauren-ciha@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix parsing of author label in query URL Fix author parsing in GitHub URLs with path-based author filters Oct 29, 2025
Copilot AI requested a review from lauren-ciha October 29, 2025 01:57
@niels9001 niels9001 marked this pull request as ready for review March 21, 2026 15:58
Copilot AI review requested due to automatic review settings March 21, 2026 15:58

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes parsing of GitHub repository “issues” / “pulls” list URLs that embed an author in the path (e.g., /pulls/<author>), so saved queries correctly include an author: qualifier instead of returning all open items.

Changes:

  • Update SearchHelper.ParseSearchStringFromUri to append author:<segment> based on the 4th URL path segment for .../issues/... and .../pulls/... routes.
  • Add unit tests covering author-in-path parsing for both pulls and issues URLs.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
GitHubExtension/Helpers/SearchHelper.cs Adds support for deriving author: from the 4th path segment on repo issues/pulls list URLs.
GitHubExtension.Test/HelpersTests/SearchHelperTests.cs Adds tests validating the new author-in-path parsing behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

[DataRow("https://github.com/microsoft/PowerToys/issues?q=is%3Aopen%20is%3Aissue%20label%3A%22Good%20first%20issue%22", "repo:microsoft/PowerToys is:open is:issue label:\"Good first issue\"")]
[DataRow("https://github.com/search?q=repo:microsoft/terminal+repo:microsoft/PowerToys+repo:microsoft/vscode+is:open+is:issue", "repo:microsoft/terminal repo:microsoft/PowerToys repo:microsoft/vscode is:open is:issue")]
[DataRow("https://github.com/microsoft/devhome/pulls/lauren-ciha", "repo:microsoft/devhome is:pr is:open author:lauren-ciha")]
[DataRow("https://github.com/microsoft/PowerToys/issues/octocat", "repo:microsoft/PowerToys is:issue is:open author:octocat")]

Copilot AI Mar 21, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a regression test to ensure numeric issue URLs (e.g., https://github.com/<owner>/<repo>/issues/123) and other non-author subpaths don’t get parsed into author:123 (or author:new). This will prevent future changes from reintroducing the bug noted in SearchHelper.ParseSearchStringFromUri.

Suggested change
[DataRow("https://github.com/microsoft/PowerToys/issues/octocat", "repo:microsoft/PowerToys is:issue is:open author:octocat")]
[DataRow("https://github.com/microsoft/PowerToys/issues/octocat", "repo:microsoft/PowerToys is:issue is:open author:octocat")]
[DataRow("https://github.com/microsoft/PowerToys/issues/123", "repo:microsoft/PowerToys is:issue is:open")]
[DataRow("https://github.com/microsoft/PowerToys/issues/new", "repo:microsoft/PowerToys is:issue is:open")]

Copilot uses AI. Check for mistakes.
Comment on lines +123 to +124
if (pathSegments.Length >= 4 && !string.IsNullOrWhiteSpace(pathSegments[3]))
{

Copilot AI Mar 21, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new path-segment author handling will also treat common non-author subpaths (e.g., an issue URL like /owner/repo/issues/123 or /owner/repo/issues/new) as an author: filter, which changes behavior and can produce incorrect/empty results. Please gate this so the 4th segment is only interpreted as an author filter when it’s not an issue/PR identifier (e.g., skip purely-numeric segments) and ideally exclude known non-filter segments (like new).

Suggested change
if (pathSegments.Length >= 4 && !string.IsNullOrWhiteSpace(pathSegments[3]))
{
bool IsPathSegmentLikelyAuthor(string segment)
{
if (string.IsNullOrWhiteSpace(segment))
{
return false;
}
// Exclude common non-author segments such as numeric IDs (issue/PR numbers)
// and known keywords like "new".
if (segment.Equals("new", StringComparison.OrdinalIgnoreCase))
{
return false;
}
var allDigits = true;
foreach (var c in segment)
{
if (!char.IsDigit(c))
{
allDigits = false;
break;
}
}
if (allDigits)
{
return false;
}
return true;
}
if (pathSegments.Length >= 4 && IsPathSegmentLikelyAuthor(pathSegments[3]))
{

Copilot uses AI. Check for mistakes.
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 this pull request may close these issues.

Author label in query URL is not parsed properly

4 participants