Skip to content

GitHub issue detail state badge mislabels PRs as merged when using issues endpoint #11641

@PekingSpades

Description

@PekingSpades

Are you experiencing an issue with...

shields.io

🐞 Description

The badge path /github/issues/detail/state/:user/:repo/:number mislabels closed-but-unmerged PRs as merged.
GitHub’s issues API for PRs omits the top-level merged_at field, so the current logic
json.merged_at !== null evaluates true when the field is missing (undefined !== null).
This makes the badge render merged incorrectly.

🔗 Link to the badge

https://img.shields.io/github/issues/detail/state/go-vgo/robotgo/753?style=flat-square

go-vgo/robotgo#753

💡 Possible Solution

When pull_request exists, use pull_request.merged_at to determine merge state.
Fallback to top-level merged_at if present. Treat null/undefined as not merged.
This fixes the misclassification without adding an extra API request.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugBugs in badges and the frontendservice-badgeNew or updated service badge

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions