Currency-blind formatting renders wrong amounts for zero- and three-decimal currencies in UCP and spend-request output
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 72/100
- issue の種類
- バグ
- 明瞭さ
- おおむね明確
- 活発さ
- 活発
- 技術スタック
- typescript
- 領域
- cli
調査の方向性
packages/cli/src/utils/format-amount.tsを読み、issueで示されている3つの呼び出し箇所と動作を比較してください。packages/cli/src/commands/ucp/__tests__/ucp.test.tsxにある既存のUCPテストを確認し、小数点以下が0桁および3桁の通貨のカバレッジを追加してください。3つすべての出力で金額が正しくフォーマットされ、通貨コードのサフィックスの動作が一貫して解決されていれば完了です。
索引モデルが issue の本文から書いたものです。
説明
Summary
Three call sites format a minor-unit amount with a hardcoded $ and /100:
packages/cli/src/commands/ucp/checkout-summary.tsx:10packages/cli/src/commands/ucp/catalog-search.tsx:31packages/cli/src/commands/spend-request/list.tsx:84
Each returns:
`$${(amount / 100).toFixed(2)} ${(currency ?? 'usd').toUpperCase()}`
A currency-aware helper already exists at packages/cli/src/utils/format-amount.ts, and it is used by transactions/list, payment-methods/list, approval-policy/retrieve, and spend-request/create. These three sites bypass it.
Actual vs expected
Amounts are in the currency's smallest unit.
| Input | Expected | Current output |
|---|---|---|
JPY 1000 |
¥1,000 |
$10.00 JPY |
KRW 5000 |
₩5,000 |
$50.00 KRW |
KWD 1000 |
KWD 1.000 |
$10.00 KWD |
EUR 1234 |
€12.34 |
$12.34 EUR |
USD 1234 |
$12.34 |
$12.34 USD |
The JPY and KRW cases are off by 100x, KWD by 10x, and every non-USD case shows the wrong symbol.
Reproduction
import { formatAmount } from './packages/cli/src/utils/format-amount';
// copied verbatim from the three call sites above
const current = (amount: number, currency: string) =>
`$${(amount / 100).toFixed(2)} ${(currency ?? 'usd').toUpperCase()}`;
formatAmount(1000, 'jpy'); // "¥1,000"
current(1000, 'jpy'); // "$10.00 JPY"
Why the current tests do not catch it
packages/cli/src/commands/ucp/__tests__/ucp.test.tsx asserts only USD strings ($99.00 USD, $25.00 USD, $0.50 USD), so only the one currency where /100 happens to be correct is exercised.
Reachability
Currency is not restricted to USD. packages/cli/src/commands/spend-request/schema.ts:40 is z.string().length(3).default('usd'), so any ISO code is accepted, and the UCP currency comes from the merchant.
Open question before a patch
The shared helper returns values without a currency-code suffix ($12.34), while these sites append the code ($12.34 USD). So the fix is a decision, not a pure swap:
- Use
formatAmountdirectly and drop the redundant code for currencies with a symbol. - Add an option to
formatAmountto append the code, and use it at all sites.
Happy to open a PR for whichever behavior you prefer.
- 主要言語
- TypeScript
- スター
- 873
- フォーク
- 147
- 平均マージ
- 23時間 53分
- マージ済み PR(30日)
- 76
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
stripe/link-cli のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
メンテナーはふだん 1 日以内に返信
-
mpp pay always fails against mppx >= 0.15 servers: "MPP challenge changed after approval" (per-challenge nonce in opaque is not excluded from the comparison)対応中かも @staubman-stripe が今日担当しました。 オープン
難易度 3/5 1〜2日 初心者へのやさしさ 72/100
stripe/link-cli#486 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
`balances list` renders non-USD balances with a `$` symbol and a fixed `/100`対応中かも @RaphaelFakhri が 3 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 25/100
メンテナーはふだん 1 日以内に返信
-
難易度 4/5 3〜5日 初心者へのやさしさ 42/100
stripe/link-cli#479 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 5/5 1週間以上 初心者へのやさしさ 1/100
メンテナーはふだん 1 日以内に返信
stripe/link-cli の issue をすべて見る
似ている issue
-
Plugin: sheet music can't be scrolled by hand before playback対応中かも @snakajima が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
receptron/jinglescript#51 ·
メンテナーはふだん 1 日以内に返信
-
enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
メンテナーはふだん 9 日以内に返信
-
clawsweeper:needs-maintainer-review clawsweeper:needs-product-decision clawsweeper:no-new-fix-pr clawsweeper:source-repro impact:ux-friction issue-rating: 🦞 diamond lobster P3
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
openclaw/openclaw#186424 · コメント 1 件 · リアクション 1 件 ·
メンテナーはふだん 1 日以内に返信
-
chore(worker): five module header comments describe the code from before later issues changed itオープンarea:dev U2-later
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
bentleypark/aiwatch#1824 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
Pal-AI-Lab/Coopanion#469 ·
メンテナーはふだん 1 日以内に返信