Skip to content

fix(logs): don't render numbers with >13 digits using commas#112354

Merged
JoshuaKGoldberg merged 1 commit intomasterfrom
joshuakgoldberg/ref/extract-discover-format-number
Apr 7, 2026
Merged

fix(logs): don't render numbers with >13 digits using commas#112354
JoshuaKGoldberg merged 1 commit intomasterfrom
joshuakgoldberg/ref/extract-discover-format-number

Conversation

@JoshuaKGoldberg
Copy link
Copy Markdown
Member

@JoshuaKGoldberg JoshuaKGoldberg commented Apr 7, 2026

Extracts a formatNumber helper for the numeric field renderer. It bypasses formatFloat for numbers that have over 13 digits.

Tangentially related:

Fixes EXP-866.

@github-actions github-actions bot added the Scope: Frontend Automatically applied to PRs that change frontend components label Apr 7, 2026
@JoshuaKGoldberg JoshuaKGoldberg force-pushed the joshuakgoldberg/ref/extract-discover-format-number branch from 7846720 to 35f4ca7 Compare April 7, 2026 13:37
@JoshuaKGoldberg JoshuaKGoldberg changed the title ref(discover): Extract formatNumber for field renderers fix(logs): don't render numbers with >=13 using commas Apr 7, 2026
@linear-code
Copy link
Copy Markdown

linear-code bot commented Apr 7, 2026

@JoshuaKGoldberg JoshuaKGoldberg force-pushed the joshuakgoldberg/ref/extract-discover-format-number branch from 35f4ca7 to f7aedb4 Compare April 7, 2026 13:47
@JoshuaKGoldberg JoshuaKGoldberg force-pushed the joshuakgoldberg/ref/extract-discover-format-number branch from f7aedb4 to e864c93 Compare April 7, 2026 13:48
Move number formatting out of fieldRenderers into a shared util, preserving
locale string output and the >10B fast path to avoid float truncation.

Add unit tests for formatNumber and integration-style tests for the number
field type in getFieldRenderer.

Co-Authored-By: Cursor <noreply@cursor.com>
Made-with: Cursor
@JoshuaKGoldberg JoshuaKGoldberg force-pushed the joshuakgoldberg/ref/extract-discover-format-number branch from e864c93 to 5d90b14 Compare April 7, 2026 13:52
@JoshuaKGoldberg JoshuaKGoldberg marked this pull request as ready for review April 7, 2026 14:01
@JoshuaKGoldberg JoshuaKGoldberg requested review from a team as code owners April 7, 2026 14:01
Comment thread static/app/utils/number/formatNumber.ts
Copy link
Copy Markdown
Contributor

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

Bugbot Autofix prepared a fix for the issue found in the latest run.

  • ✅ Fixed: Formatting function has inconsistent return type
    • Changed formatNumber to return String(value) for large numbers instead of raw number, ensuring consistent string return type across all code paths and aligning with other formatting utilities.

Create PR

Or push these changes by commenting:

@cursor push 0f0e338f92
Preview (0f0e338f92)
diff --git a/static/app/utils/number/formatNumber.spec.ts b/static/app/utils/number/formatNumber.spec.ts
--- a/static/app/utils/number/formatNumber.spec.ts
+++ b/static/app/utils/number/formatNumber.spec.ts
@@ -10,11 +10,11 @@
   });
 
   it('returns the value when the value has 14 digits', () => {
-    expect(formatNumber(12_345_678_901_234)).toBe(12345678901234);
+    expect(formatNumber(12_345_678_901_234)).toBe('12345678901234');
   });
 
   it('returns the value when the value has 15 digits', () => {
-    expect(formatNumber(123_456_789_012_345)).toBe(123456789012345);
+    expect(formatNumber(123_456_789_012_345)).toBe('123456789012345');
   });
 
   it('returns the value when the value does not have digits', () => {

diff --git a/static/app/utils/number/formatNumber.ts b/static/app/utils/number/formatNumber.ts
--- a/static/app/utils/number/formatNumber.ts
+++ b/static/app/utils/number/formatNumber.ts
@@ -4,7 +4,7 @@
 
 export function formatNumber(value: number) {
   if (value >= 10_000_000_000_000) {
-    return value;
+    return String(value);
   }
 
   return formatFloat(value, NUMBER_MAX_FRACTION_DIGITS).toLocaleString(undefined, {

This Bugbot Autofix run was free. To enable autofix for future PRs, go to the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 5d90b14. Configure here.

Comment thread static/app/utils/number/formatNumber.ts
Copy link
Copy Markdown
Contributor

@nsdeschenes nsdeschenes left a comment

Choose a reason for hiding this comment

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

All looks good, can you update the PR title to match the changes as well, just so the commit message matches everything 🙏

@JoshuaKGoldberg
Copy link
Copy Markdown
Member Author

D'oh!

@JoshuaKGoldberg JoshuaKGoldberg changed the title fix(logs): don't render numbers with >=13 using commas fix(logs): don't render numbers with >13 digits using commas Apr 7, 2026
@JoshuaKGoldberg JoshuaKGoldberg merged commit 7c7bdcb into master Apr 7, 2026
75 checks passed
@JoshuaKGoldberg JoshuaKGoldberg deleted the joshuakgoldberg/ref/extract-discover-format-number branch April 7, 2026 15:40
george-sentry pushed a commit that referenced this pull request Apr 9, 2026
Extracts a `formatNumber` helper for the numeric field renderer. It
bypasses `formatFloat` for numbers that have over 13 digits.

Tangentially related:

* #110360
* #110858

Fixes EXP-866.

Co-authored-by: Cursor <noreply@cursor.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Frontend Automatically applied to PRs that change frontend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants