Skip to content

Fix: Improve PR number validation and warning messages in input handling#939

Merged
HarithaVattikuti merged 3 commits into
actions:mainfrom
chiranjib-swain:fix/pr-number-validation-guard
Jun 22, 2026
Merged

Fix: Improve PR number validation and warning messages in input handling#939
HarithaVattikuti merged 3 commits into
actions:mainfrom
chiranjib-swain:fix/pr-number-validation-guard

Conversation

@chiranjib-swain

@chiranjib-swain chiranjib-swain commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

Description:
This pull request enhances the validation and handling of the pr-number input for pull requests, ensuring that only valid, positive integers are processed and that invalid or malformed inputs are clearly reported with sanitized warnings. It also adds comprehensive test coverage for these scenarios.

Test coverage improvements:

  • Added multiple test cases to main.test.ts to verify that the action warns and skips API calls for various invalid pr-number inputs, including non-numeric strings, negative numbers, zero, numbers with spaces or non-numeric characters, and strings with non-printable or ANSI escape characters. The tests also confirm that valid numbers with whitespace are handled correctly and that a mix of valid and invalid inputs processes only the valid ones.

Input validation and sanitization enhancements:

  • Introduced a sanitizeForWarning function in get-pr-numbers.ts to escape non-printable characters in warning messages, making them more readable and secure.
  • Improved the getPrNumbers function to:
    • Trim whitespace from each input.
    • Accept only positive integers that match the trimmed input exactly.
    • Provide clear warnings for invalid inputs, using the new sanitization function and including a hint when non-printable characters are detected.

Related issue:
#937

Check list:

  • Mark if documentation changes are required.
  • Mark if tests were added or updated to cover the changes.

Copilot AI review requested due to automatic review settings June 3, 2026 14:40
@chiranjib-swain chiranjib-swain requested a review from a team as a code owner June 3, 2026 14:40
@chiranjib-swain chiranjib-swain self-assigned this Jun 3, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes validation for the pr-number input so invalid values (non-numeric, zero, negative) are rejected before reaching the GitHub API, and it improves the warning message to echo what the user actually typed.

Changes:

  • Fixes the validation condition in get-pr-numbers.ts from && to || so NaN, 0, and negative values are all rejected.
  • Updates the warning message to reference the raw input line rather than the parsed result.
  • Adds test coverage for invalid and mixed-validity pr-number inputs and updates the built dist/index.js accordingly.

Reviewed changes

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

File Description
src/get-inputs/get-pr-numbers.ts Corrects PR number validation logic and improves warning clarity.
dist/index.js Updates the compiled distribution output to match the source fix.
tests/main.test.ts Adds tests ensuring invalid pr-number inputs warn and avoid API calls, and mixed inputs still process valid PRs.

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

mahabaleshwars
mahabaleshwars previously approved these changes Jun 4, 2026
priya-kinthali
priya-kinthali previously approved these changes Jun 4, 2026
@chiranjib-swain chiranjib-swain mentioned this pull request Jun 5, 2026
5 tasks

@chaoscommencer chaoscommencer left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I'm not familiar with the configuration requirements for the unit tests, but the character validation looks good!

@HarithaVattikuti HarithaVattikuti merged commit f612d9a into actions:main Jun 22, 2026
4 of 7 checks passed
@chiranjib-swain chiranjib-swain deleted the fix/pr-number-validation-guard branch June 24, 2026 03:52
eleboucher pushed a commit to eleboucher/homelab that referenced this pull request Jul 9, 2026
…v6.1.0 ➔ v6.2.0) (#1478)

This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [https://github.com/actions/labeler](https://github.com/actions/labeler) | action | minor | `v6.1.0` → `v6.2.0` |

---

### Release Notes

<details>
<summary>actions/labeler (https://github.com/actions/labeler)</summary>

### [`v6.2.0`](https://github.com/actions/labeler/releases/tag/v6.2.0)

[Compare Source](actions/labeler@v6.1.0...v6.2.0)

#### What's Changed

##### Bug Fix

- Improve PR number validation and warning messages in input handling by [@&#8203;chiranjib-swain](https://github.com/chiranjib-swain) in [#&#8203;939](actions/labeler#939)

##### Dependency Updates

- Bump js-yaml to 4.2.0, apply npm audit fix, and add undici override  by [@&#8203;dependabot](https://github.com/dependabot) in [#&#8203;943](actions/labeler#943)
- Bump [@&#8203;typescript-eslint/eslint-plugin](https://github.com/typescript-eslint/eslint-plugin) from 8.59.1 to 8.61.1 by [@&#8203;dependabot](https://github.com/dependabot) in [#&#8203;942](actions/labeler#942)

**Full Changelog**: <actions/labeler@v6.1.0...v6.2.0>

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0My4xMDEuMSIsInVwZGF0ZWRJblZlciI6IjQzLjEwMS4xIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJyZW5vdmF0ZS9naXRodWItYWN0aW9uIiwidHlwZS9taW5vciJdfQ==-->

Reviewed-on: https://git.erwanleboucher.dev/eleboucher/homelab/pulls/1478
hbjydev pushed a commit to hbjydev/phoebe that referenced this pull request Jul 9, 2026
…v6.1.0 → v6.2.0) (#234)

This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [https://github.com/actions/labeler](https://github.com/actions/labeler) | action | minor | `v6.1.0` → `v6.2.0` |

---

### Release Notes

<details>
<summary>actions/labeler (https://github.com/actions/labeler)</summary>

### [`v6.2.0`](https://github.com/actions/labeler/releases/tag/v6.2.0)

[Compare Source](actions/labeler@v6.1.0...v6.2.0)

#### What's Changed

##### Bug Fix

- Improve PR number validation and warning messages in input handling by [@&#8203;chiranjib-swain](https://github.com/chiranjib-swain) in [#&#8203;939](actions/labeler#939)

##### Dependency Updates

- Bump js-yaml to 4.2.0, apply npm audit fix, and add undici override  by [@&#8203;dependabot](https://github.com/dependabot) in [#&#8203;943](actions/labeler#943)
- Bump [@&#8203;typescript-eslint/eslint-plugin](https://github.com/typescript-eslint/eslint-plugin) from 8.59.1 to 8.61.1 by [@&#8203;dependabot](https://github.com/dependabot) in [#&#8203;942](actions/labeler#942)

**Full Changelog**: <actions/labeler@v6.1.0...v6.2.0>

</details>

---

### Configuration

📅 **Schedule**: (in timezone Europe/London)

- Branch creation
  - At any time (no schedule defined)
- Automerge
  - At any time (no schedule defined)

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Mend Renovate](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0My4yNDIuMSIsInVwZGF0ZWRJblZlciI6IjQzLjI0Mi4xIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJyZW5vdmF0ZS9naXRodWItYWN0aW9uIiwidHlwZS9taW5vciJdfQ==-->

Reviewed-on: https://forgejo.hayden.moe/hayden/phoebe/pulls/234
doonga pushed a commit to greyrock-labs/home-ops that referenced this pull request Jul 9, 2026
…v6.1.0 ➔ v6.2.0) (#490)

This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [https://github.com/actions/labeler](https://github.com/actions/labeler) | action | minor | `v6.1.0` → `v6.2.0` |

---

### Release Notes

<details>
<summary>actions/labeler (https://github.com/actions/labeler)</summary>

### [`v6.2.0`](https://github.com/actions/labeler/releases/tag/v6.2.0)

[Compare Source](actions/labeler@v6.1.0...v6.2.0)

#### What's Changed

##### Bug Fix

- Improve PR number validation and warning messages in input handling by [@&#8203;chiranjib-swain](https://github.com/chiranjib-swain) in [#&#8203;939](actions/labeler#939)

##### Dependency Updates

- Bump js-yaml to 4.2.0, apply npm audit fix, and add undici override  by [@&#8203;dependabot](https://github.com/dependabot) in [#&#8203;943](actions/labeler#943)
- Bump [@&#8203;typescript-eslint/eslint-plugin](https://github.com/typescript-eslint/eslint-plugin) from 8.59.1 to 8.61.1 by [@&#8203;dependabot](https://github.com/dependabot) in [#&#8203;942](actions/labeler#942)

**Full Changelog**: <actions/labeler@v6.1.0...v6.2.0>

</details>

---

### Configuration

📅 **Schedule**: (in timezone America/New_York)

- Branch creation
  - At any time (no schedule defined)
- Automerge
  - At any time (no schedule defined)

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Mend Renovate](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0My4yNTIuMSIsInVwZGF0ZWRJblZlciI6IjQzLjI1Mi4xIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJyZW5vdmF0ZS9naXRodWItYWN0aW9uIiwicmVub3ZhdGUvZ2l0aHViLXJlbGVhc2UiLCJ0eXBlL21pbm9yIl19-->

Reviewed-on: https://git.greyrock.io/greyrock-labs/home-ops/pulls/490
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.

6 participants