Skip to content

Comments

fix: Issue #1309#1519

Merged
maxprilutskiy merged 8 commits intolingodotdev:mainfrom
Dishantydv7:fix/status-nan-percentage
Nov 17, 2025
Merged

fix: Issue #1309#1519
maxprilutskiy merged 8 commits intolingodotdev:mainfrom
Dishantydv7:fix/status-nan-percentage

Conversation

@Dishantydv7
Copy link
Contributor

"Fixes #1309 — guard against division-by-zero in packages/cli/src/cli/cmd/status.ts. Returns 0.0% when totalWordsToTranslate is 0. "

This occurs when all target locales have 100% translation completion, causing division by zero: (0 / 0) * 100 = NaN

Addresses CI/CD pipeline failures, monitoring integration issues, and stakeholder confusion outlined in #1309

- Add zero-division check before calculating percentage (line 410)
- Display '0.0%' instead of 'NaN%' when totalWordsToTranslate is 0
- Fixes #{ISSUE_NUMBER}

This occurs when all target locales have 100% translation completion,
causing division by zero: (0 / 0) * 100 = NaN

Addresses CI/CD pipeline failures, monitoring integration issues,
and stakeholder confusion outlined in #{ISSUE_NUMBER}
Copy link
Contributor

@The-Best-Codes The-Best-Codes left a comment

Choose a reason for hiding this comment

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

Nice PR 🎉

Don't forget to run pnpm run format and add a changeset with pnpm new before this PR can be merged!

Copy link
Contributor

@The-Best-Codes The-Best-Codes left a comment

Choose a reason for hiding this comment

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

👍

Copy link
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

This PR fixes a division-by-zero issue in the status command that causes "NaN%" to be displayed when all target locales have 100% translation completion. The fix adds a guard to check if totalWordsToTranslate is zero before performing the division.

Key changes:

  • Added conditional check to prevent division by zero when calculating per-language breakdown percentages
  • Returns "0.0" when totalWordsToTranslate is 0 instead of computing NaN

Reviewed Changes

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

File Description
packages/cli/src/cli/cmd/status.ts Added guard condition to prevent division by zero in per-language breakdown percentage calculation
.changeset/rude-spies-smoke.md Added changeset entry documenting the bug fix

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

@sumitsaurabh927
Copy link
Contributor

@Dishantydv7 there's a failing check, please resolve this and I'll merge.

@maxprilutskiy maxprilutskiy merged commit 5d808bd into lingodotdev:main Nov 17, 2025
3 checks passed
17prateek12 pushed a commit to 17prateek12/lingo.dev that referenced this pull request Jan 23, 2026
* fix: prevent NaN% in status command when all translations complete

- Add zero-division check before calculating percentage (line 410)
- Display '0.0%' instead of 'NaN%' when totalWordsToTranslate is 0
- Fixes #{ISSUE_NUMBER}

This occurs when all target locales have 100% translation completion,
causing division by zero: (0 / 0) * 100 = NaN

Addresses CI/CD pipeline failures, monitoring integration issues,
and stakeholder confusion outlined in #{ISSUE_NUMBER}

* chore: fix code style issues in status.ts

* chore(changeset): add changeset for fix/status-nan-percentage

---------

Co-authored-by: Max Prilutskiy <5614659+maxprilutskiy@users.noreply.github.com>
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.

Division by Zero Error Producing NaN% in Status Command Output

4 participants