Skip to content

fix: separate duplicate erms validation in insertErms#67422

Merged
ojeytonwilliams merged 3 commits into
freeCodeCamp:mainfrom
Nithin0620:fix/insert-erms-duplicate-check
May 15, 2026
Merged

fix: separate duplicate erms validation in insertErms#67422
ojeytonwilliams merged 3 commits into
freeCodeCamp:mainfrom
Nithin0620:fix/insert-erms-duplicate-check

Conversation

@Nithin0620

@Nithin0620 Nithin0620 commented May 15, 2026

Copy link
Copy Markdown
Contributor

Checklist:

Description

This PR fixes a logic error in the insertErms function where duplicate error checks prevented the second validation from ever being reached.

What changed:

  • Split the combined condition if (!erms || erms.length <= 1) into two separate checks
  • First check validates that erms is provided
  • Second check validates that erms contains at least 2 elements

Why:
The original code had the second error check as unreachable dead code because the first condition would throw if erms.length <= 1, so the second check could never execute.


Closes #67427

@Nithin0620 Nithin0620 requested review from a team as code owners May 15, 2026 07:56
@github-actions github-actions Bot added scope: tools/scripts Scripts for supporting dev work, generating config and build artifacts, etc. deprioritized PR reviews are deprioritized; lacks productive input and ignores codebase best practices. labels May 15, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Hi there,

Thanks for opening this pull request.

The automated checks found some issues:

Linked Issue: We kindly ask that contributors open an issue before submitting a PR so the change can be discussed and approved before work begins. This helps avoid situations where significant effort goes into something we ultimately cannot merge.

Please open an issue first and allow it to be triaged. Once the issue is open for contribution, you are welcome to update this pull request to reflect the issue consensus. Until then, we will not be able to review your pull request.


Join us in our chat room or our forum if you have any questions or need help with contributing.

Comment thread tools/challenge-helper-scripts/helpers/insert-erms.ts Outdated
@majestic-owl448 majestic-owl448 added status: waiting update Is awaiting update, after feedback or request for changes and removed deprioritized PR reviews are deprioritized; lacks productive input and ignores codebase best practices. labels May 15, 2026
@ojeytonwilliams ojeytonwilliams added status: waiting review To be applied to PR's that are ready for QA, especially when additional review is pending. and removed status: waiting update Is awaiting update, after feedback or request for changes labels May 15, 2026

@ojeytonwilliams ojeytonwilliams 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.

LGTM 👍 Thanks, @Nithin0620

@ojeytonwilliams ojeytonwilliams merged commit a2e0622 into freeCodeCamp:main May 15, 2026
11 checks passed
@github-actions github-actions Bot locked as resolved and limited conversation to collaborators May 15, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

scope: tools/scripts Scripts for supporting dev work, generating config and build artifacts, etc. status: waiting review To be applied to PR's that are ready for QA, especially when additional review is pending.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix unreachable duplicate validation logic in insertErms

3 participants