From f7b6e467cd6ccc9b3cdc574d87abda87dd5631b6 Mon Sep 17 00:00:00 2001 From: Djordje Date: Thu, 26 Feb 2026 14:21:18 +0100 Subject: [PATCH] Fix string CLI arguments being passed through JSON.parse MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit String option values (e.g. --query "Netflix", --product_id "steam-usa") were falling through to the default case in coerceValue which called JSON.parse, causing parse errors. Now only object/array types use JSON.parse; all other types return the raw string. Also fixes incorrect command names in README (underscores → hyphens). --- README.md | 4 ++-- src/index.ts | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index fdbabd0..3b46884 100644 --- a/README.md +++ b/README.md @@ -27,10 +27,10 @@ On first run, the CLI will open your browser for OAuth authorization. Credential bitrefill search-products --query "Netflix" # Get product details -bitrefill get_product_details --product_id "steam-usa" --currency USDC +bitrefill get-product-details --product_id "steam-usa" --currency USDC # Buy a product -bitrefill buy_products --cart_items '{"product_id": "steam-usa", "package_id": 10}' --payment_method usdc_base +bitrefill buy-products --cart_items '{"product_id": "steam-usa", "package_id": 10}' --payment_method usdc_base # List your orders bitrefill list-orders diff --git a/src/index.ts b/src/index.ts index 0eb2042..fa6658f 100644 --- a/src/index.ts +++ b/src/index.ts @@ -253,8 +253,11 @@ function coerceValue(raw: string, prop: JsonSchemaProperty): unknown { if (['true', '1', 'yes'].includes(raw)) return true; if (['false', '0', 'no'].includes(raw)) return false; throw new Error('Must be true/false'); - default: + case 'object': + case 'array': return JSON.parse(raw); + default: + return raw; } }