Skip to content

Synthesize PR html_url so dedup drops duplicate lines#330

Merged
masutaka merged 1 commit into
mainfrom
fix-duplicate-lines
Apr 29, 2026
Merged

Synthesize PR html_url so dedup drops duplicate lines#330
masutaka merged 1 commit into
mainfrom
fix-duplicate-lines

Conversation

@masutaka
Copy link
Copy Markdown
Owner

@masutaka masutaka commented Apr 29, 2026

Background

Running ./github-nippou produced duplicate lines for the same PR:

- [Replace deprecated 'app-id' input in create-github-app-token](https://github.com/masutaka/github-nippou/pull/329)
- [Replace deprecated 'app-id' input in create-github-app-token](https://github.com/masutaka/github-nippou/pull/329)

(*Events).uniq dedups by the URL pulled out of each event payload (htmlURL in lib/events.go). For PR-related events it read payload.PullRequest.HTMLURL, but the /users/{user}/events API returns the pull_request payload without html_url (only number is set). Verified directly:

$ gh api 'users/masutaka/events?per_page=30' \
    --jq '.[] | select(.type=="PullRequestEvent") | {pr_url: .payload.pull_request.html_url, pr_number: .payload.pull_request.number}'
{"pr_number":329,"pr_url":null}
{"pr_number":329,"pr_url":null}
{"pr_number":327,"pr_url":null}
...

This caused two distinct symptoms:

  • Duplicate lines. The first PullRequestEvent on PR Replace deprecated 'app-id' input in create-github-app-token #329 (dedup key "") and the corresponding IssueCommentEvent on the same PR (dedup key /pull/329 from issue.html_url) had different keys, so both passed uniq. Format.Line then resolved both to the same /pull/329 URL — producing two identical lines.
  • Silently dropped PRs. Every PullRequestEvent / PullRequestReviewEvent / PullRequestReviewCommentEvent mapped to "", so only the first one survived uniq. Other PRs touched only by these event types in the same range were dropped from the output entirely. In my reproduction PRs Support DiscussionEvent #326 and Fix deprecate warnings #327 were missing.

Changes

  • Add pullRequestHTMLURL(event, number) which synthesizes https://github.com/{repo}/pull/{number} from event.Repo.Name + payload.PullRequest.Number. This matches the /pull/N form IssueCommentEvent.Issue.HTMLURL already returns for PR comments, so dedup keys align across the two event families.
  • Switch the three PR-related cases in htmlURL to use it. The nil check moves from e.PullRequest.HTMLURL != nil to e.PullRequest.Number != nil, since Number is what the API actually populates.
  • IssuesEvent / IssueCommentEvent / DiscussionEvent are unchanged — their payload html_url fields are populated correctly by the API.

Verification

Before:

- [Support DiscussionEvent](.../issues/227) (Done)
- [Replace deprecated 'app-id' input in create-github-app-token](.../issues/328)
- [Replace deprecated 'app-id' input in create-github-app-token](.../pull/329)
- [Replace deprecated 'app-id' input in create-github-app-token](.../pull/329)  # duplicate
# PRs #326 and #327 missing

After:

- [Support DiscussionEvent](.../issues/227) (Done)
- [Replace deprecated 'app-id' input in create-github-app-token](.../issues/328)
- [Support DiscussionEvent](.../pull/326) (Done)
- [Fix deprecate warnings](.../pull/327) (Done)
- [Replace deprecated 'app-id' input in create-github-app-token](.../pull/329)

@masutaka masutaka self-assigned this Apr 29, 2026
@masutaka masutaka added the bug label Apr 29, 2026
@masutaka masutaka marked this pull request as ready for review April 29, 2026 12:59
@masutaka masutaka merged commit a81fe38 into main Apr 29, 2026
8 checks passed
@masutaka masutaka deleted the fix-duplicate-lines branch April 29, 2026 12:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant