Skip to content

fix: correct item.State to item.state for PR action label detection#536

Open
PhilixTheExplorer wants to merge 1 commit intofossasia:mainfrom
PhilixTheExplorer:fix/pr-action-label-case-typo
Open

fix: correct item.State to item.state for PR action label detection#536
PhilixTheExplorer wants to merge 1 commit intofossasia:mainfrom
PhilixTheExplorer:fix/pr-action-label-case-typo

Conversation

@PhilixTheExplorer
Copy link
Copy Markdown

@PhilixTheExplorer PhilixTheExplorer commented Apr 12, 2026

📌 Fixes

Fixes #535


📝 Summary of Changes

  • Fixed incorrect property case item.State (capital S) → item.state (lowercase s) on line 1768 (GitHub) and line 1775 (GitLab) in scrumHelper.js
  • Fixed wrong state value for GitLab: 'open''opened' on line 1775, since the GitLab Merge Requests API returns opened, closed, locked, or merged — not open
  • The GitHub Issues API returns open or closed, which was already correct for the GitHub path but never matched due to the capital S typo

Root cause: The condition item.State === 'open' never evaluated to true because:

  1. Both APIs return the property as lowercase state, not State
  2. GitLab uses opened not open for merge requests

This caused PRs/MRs created today to always show "Updated PR" / "Updated Merge Request" instead of "Made PR" / "Made Merge Request".


📸 Screenshots / Demo (if UI-related)

label-bug
Before

After

✅ Checklist

  • I've tested my changes locally
  • I've added tests (if applicable)
  • I've updated documentation (if applicable)
  • My code follows the project's code style guidelines

👀 Reviewer Notes

The mapGitLabItem() function (lines 272, 342) already normalizes GitLab's openedopen for issues, but passes through the raw state for merge requests. That's why the GitLab path on line 1775 must compare against 'opened' rather than 'open'.

Summary by Sourcery

Correct PR/MR action labeling based on creation date and platform-specific state values.

Bug Fixes:

  • Fix GitHub PR action detection by using the correct lowercase state property when checking for newly created PRs.
  • Fix GitLab merge request action detection by comparing against the correct 'opened' state for newly created merge requests.

Copilot AI review requested due to automatic review settings April 12, 2026 09:09
@sourcery-ai
Copy link
Copy Markdown
Contributor

sourcery-ai bot commented Apr 12, 2026

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Adjusts PR/MR action label logic in scrumHelper.js so that 'Made PR' / 'Made Merge Request' are correctly detected based on the actual API response fields and values from GitHub and GitLab.

Flow diagram for PR/MR action label determination logic

flowchart TD
  A[Start label determination] --> B{Platform}
  B -->|github| C[Set prAction to
isNewPR ? Made PR : Updated PR]
  B -->|gitlab| D[Set prAction to
isNew Merge Request : Updated Merge Request]

  C --> E{isCreatedToday
and item.state == open?}
  E -->|yes| F[Set prAction to
Made PR]
  E -->|no| G[Set prAction to
Updated PR]

  D --> H{isCreatedToday
and item.state == opened?}
  H -->|yes| I[Set prAction to
Made Merge Request]
  H -->|no| J[Set prAction to
Updated Merge Request]

  F --> K[Return prAction]
  G --> K
  I --> K
  J --> K
  K[End]
Loading

File-Level Changes

Change Details Files
Fix conditional logic for detecting newly created GitHub PRs so that 'Made PR' is correctly assigned when appropriate.
  • Use the correct lowercase property name from the API response when checking the PR state
  • Keep the existing check for the 'open' state value when evaluating whether the PR was created today
src/scripts/scrumHelper.js
Fix conditional logic for detecting newly created GitLab merge requests so that 'Made Merge Request' is correctly assigned when appropriate.
  • Use the correct lowercase property name from the API response when checking the merge request state
  • Update the expected state value from 'open' to 'opened' to match the GitLab Merge Requests API when evaluating whether the MR was created today
src/scripts/scrumHelper.js

Assessment against linked issues

Issue Objective Addressed Explanation
#535 Use the correct lowercase state property instead of State when determining whether a PR/MR created today should be labeled as 'Made PR' / 'Made Merge Request'.
#535 Use the correct GitLab merge request open-state value ('opened') when determining whether a GitLab MR created today should be labeled as 'Made Merge Request' instead of 'Updated Merge Request'.

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@github-actions github-actions bot added javascript Pull requests that update javascript code core labels Apr 12, 2026
Copy link
Copy Markdown
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey - I've left some high level feedback:

  • The isCreatedToday + state check is duplicated across the GitHub and GitLab branches; consider extracting a small helper (e.g. isNewlyOpened(item, platform)) or normalizing state earlier so the PR/MR action label logic is shared.
  • To avoid future state-name mismatches (open vs opened), it may be safer to normalize the raw API state into a common internal enum/string in the existing mapping functions and compare only against that here.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The `isCreatedToday` + state check is duplicated across the GitHub and GitLab branches; consider extracting a small helper (e.g. `isNewlyOpened(item, platform)`) or normalizing state earlier so the PR/MR action label logic is shared.
- To avoid future state-name mismatches (`open` vs `opened`), it may be safer to normalize the raw API state into a common internal enum/string in the existing mapping functions and compare only against that here.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes PR/MR action label detection in the scrum report by correcting state property casing and aligning GitLab’s open state value with the API response, so items created today can be labeled as “Made PR” / “Made Merge Request” correctly.

Changes:

  • Corrected item.Stateitem.state for GitHub PR action detection.
  • Updated GitLab MR open-state comparison from 'open''opened'.

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

Comment on lines 1765 to 1769
prAction = isNewPR ? 'Made PR' : 'Updated PR';
log(`[PR DEBUG] Including PR #${number} as ${prAction}`);

if (isCreatedToday && item.State === 'open') {
if (isCreatedToday && item.state === 'open') {
prAction = 'Made PR';
Copy link

Copilot AI Apr 12, 2026

Choose a reason for hiding this comment

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

The debug log prints prAction before it gets recalculated by the isCreatedToday branch, so the log message can disagree with the final label rendered (e.g., isNewPR true but isCreatedToday false). Consider computing prAction once (or moving the log after the final assignment) to keep logs and output consistent.

Copilot uses AI. Check for mistakes.
Comment on lines 1773 to 1776
} else if (platform === 'gitlab') {
prAction = isNewPR ? 'Made Merge Request' : 'Updated Merge Request';
if (isCreatedToday && item.State === 'open') {
if (isCreatedToday && item.state === 'opened') {
prAction = 'Made Merge Request';
Copy link

Copilot AI Apr 12, 2026

Choose a reason for hiding this comment

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

GitLab MR state handling is now split between 'open' and 'opened' checks in this function, while mapGitLabItem normalizes 'opened' -> 'open' only for issues. To reduce scattered platform-specific string checks, consider normalizing MR state in mapGitLabItem as well so the rest of the code can consistently compare against 'open'.

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

core javascript Pull requests that update javascript code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] PRs created today always show "Updated PR" instead of "Made PR" due to wrong property case

2 participants