You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
JSON Parse Error - Unterminated String on Write Tool #11531
Model: kimi-k2.5-free Tool Affected:write (file write) Error:JSON Parse error: Unterminated string
Summary
Large content strings (>4-5KB) with code blocks cause JSON parsing failures when using the write tool.
Reproduction
⚙ invalid [tool=write, error=Invalid input for tool write: JSON parsing failed: Text: {"content": "# TownHub - Multi-Town Community Platform\n## Technical Specification Document v1.0\n\n---\n\n## 1. EXECUTIVE SUMMARY\n\nProduct Name: TownHub\nPurpose: Hyperlocal platform connecting residents with local businesses, events, and community information across multiple towns.\nTarget Market: South African towns (initially), with global scalability potential.\nRevenue Model: Freemium SaaS (business subscriptions) + transaction fees + advertising\nTech Stack: Laravel API (Backend) + Nuxt.js (Web) + Flutter (Mobile)\n\n---\n\n## 2. USER PERSONAS & USER STORIES\n\n### 2.1 User Types\n\nType A: Resident (Free User)\n- Discovers local businesses, events, and community updates\n- Can browse, search, review, and engage\n- Can post classifieds (limited free listings)\n- Can RSVP to events\n- Can message businesses\n\nType B: Business Owner\n- Basic tier: Free limited listing\n- Premium tier: R299/month - enhanced profile, analytics, unlimited deals\n- Pro tier: R699/month - booking system, priority placement, customer messaging\n- Enterprise: R999/month - white-label, API access, dedicated support\n\nType C: Town Administrator\n- Manages town settings and content moderation\n- Can broadcast emergency notifications\n- Views town analytics\n- Approves/rejects business claims\n\nType D: Super Admin (Platform Owner)\n- Manages all towns\n- User management across platform\n- Revenue analytics\n- System configuration\n\n### 2.2 Detailed User Stories\n\nAs a Resident:\n1. I want to join my town so I can see local content\n2. I want to search for businesses by category and location\n3. I want to view business details including hours, photos, and reviews\n4. I want to leave reviews and ratings for businesses I've visited\n5. I want to see upcoming events in my town and RSVP\n6. I want to buy/sell items locally through classifieds\n7. I want to receive notifications for events I'm attending\n8. I want to save businesses to favorites\n9. I want to share business listings via WhatsApp/SMS\n10. I want to see which businesses are currently open\n\nAs a Business Owner:\n1. I want to claim my business listing\n2. I want to update my business profile with photos, hours, description\n3. I want to create and manage deals/offers\n4. I want to post events to promote to the community\n5. I want to respond to customer reviews\n6. I want to see analytics on profile views and engagement\n7. I want to receive messages from potential customers\n8. I want to manage my subscription and billing\n9. I want to export customer data (with permissions)\n10. I want to integrate booking/appointment scheduling\n\nAs a Town Admin:\n1. I want to moderate community posts and remove inappropriate content\n2. I want to send broadcast notifications to all residents\n3. I want to approve business registrations in my town\n4. I want to view engagement metrics for my town\n5. I want to feature specific businesses or events\n6. I want to configure town-specific settings (categories, rules)\n7. I want to manage town residents and ban problematic users\n8. I want to export town analytics reports\n\n---\n\n## 3. DETAILED FEATURE SPECIFICATIONS\n\n### 3.1 AUTHENTICATION & USER MANAGEMENT\n\n3.1.1 Authentication System\n- Email/password registration with verification\n- Social login: Google, Facebook, Apple\n- Phone number verification (OTP via SMS)\n- JWT token-based authentication (Sanctum)\n- Password reset via email\n- Session management with refresh tokens\n- Rate limiting on login attempts (5 attempts per 15 minutes)\n\n3.1.2 User Profiles\nFields:\n- id (UUID)\n- email (unique, required)\n- phone_number (unique, optional)\n- first_name (required)\n- last_name (required)\n- avatar_url (nullable)\n- bio (text, max 500 chars, nullable)\n- date_of_birth (nullable)\n- gender (enum: male, female, other, prefer_not_to_say, nullable)\n- town_ids (array, many-to-many)\n- current_town_id (FK, nullable)\n- user_type (enum: resident, business_owner, town_admin, super_admin)\n- is_verified (boolean, default: false)\n- email_verified_at (timestamp)\n- phone_verified_at (timestamp)\n- notification_preferences (JSON)\n- privacy_settings (JSON)\n- created_at, updated_at, deleted_at\n\n3.1.3 User Roles & Permissions\nRoles:\n- resident: Basic browsing and engagement\n- business_owner: Can manage owned businesses\n- town_admin: Can moderate content in assigned towns\n- super_admin: Full platform access\n\nPermissions implemented via Laravel Spatie or custom middleware:\n- view_businesses\n- create_business\n- edit_own_business\n- delete_own_business\n- post_classified\n- create_event\n- moderate_content\n- broadcast_notifications\n- view_analytics\n- manage_subscriptions\n\n### 3.2 TOWN MANAGEMENT\n\n3.2.1 Town Entity\nFields:\n- id (UUID)\n- name (required, unique per country)\n- slug (required, URL-friendly)\n- description (text)\n- country (required, default: ZA)\n- province (required for SA)\n- city/town classification\n- latitude, longitude (for geofencing)\n- radius_km (service area radius)\n- cover_image_url\n- logo_url\n- primary_color, secondary_color (for branding)\n- timezone (default: Africa/Johannesburg)\n- currency (default: ZAR)\n- is_active (boolean)\n- is_featured (boolean)\n- settings (JSON: moderation_rules, posting_limits, etc.)\n- created_by (FK to users)\n- created_at, updated_at\n\n3.2.2 User-Town Relationship\nTable: user_town_memberships\n- id\n- user_id (FK)\n- town_id (FK)\n- role (enum: member, moderator, admin)\n- joined_at (timestamp)\n- is_primary (boolean)\n- notification_enabled (boolean)\n\n3.2.3 Town Joining Logic\n- Users can join multiple towns\n- User selects primary town (default view)\n- Can switch towns via town selector\n- Can discover nearby towns via geolocation\n- Must be approved to join private towns (rare)\n\n### 3.3 BUSINESS DIRECTORY\n\n3.3.1 Business Entity\nFields:\n- id (UUID)\n- name (required, max 255)\n- slug (required, unique per town)\n- description (text, max 5000)\n- short_description (text, max 160, for SEO)\n- town_id (FK, required)\n- owner_user_id (FK, nullable until claimed)\n- category_id (FK, required)\n- subcategory_ids (array of FKs)\n- status (enum: pending, active, suspended, closed)\n- verification_status (enum: unclaimed, pending, verified, rejected)\n\nContact Information:\n- phone_number (required)\n- whatsapp_number (nullable)\n- email (required)\n- website_url (nullable)\n- social_links (JSON: facebook, instagram, twitter, linkedin, tiktok)\n\nLocation:\n- address_line_1 (required)\n- address_line_2 (nullable)\n- suburb (required)\n- postal_code (required)\n- latitude (required)\n- longitude (required)\n- google_place_id (nullable)\n\nBusiness Details:\n- business_type (enum: physical, online, both)\n- year_established (nullable)\n- employee_count (enum: solo, 2-5, 6-10, 11-25, 26-50, 50+)\n- tags (array of strings, max 10)\n\nMedia:\n- logo_url (nullable)\n- cover_image_url (nullable)\n- gallery_images (array of URLs, max 20)\n-.
Error message: JSON Parse error: Unterminated string]
I had this issue and it's a real PITA because everything stops and it seems opencode doesn't realise. If I tell it the error and tell it to use a sub agent then it will eventually work. I assume it sees the error output from the sub agent but not from itself.
make sure you are on latest, if you installed via brew make sure you are using correct tap: brew install anomalyco/tap/opencode
This was fixed in 1.1.41
brew info opencode
==> opencode ✔: stable 1.1.50 (bottled)
the problem still appeared when write into file with a large content which are produced by ai model.
temp solution
⚙ invalid [tool=write, error=Invalid input for tool write: JSON parsing failed: Text: {"filePath": "xxxx.md".
Error message: JSON Parse error: Expected '}']
▣ Build · claude-sonnet · 2m 39s
Promot:Do not write all at once; write in batches to avoid writing issues.
it works
Activity
github-actions commentedon Jan 31, 2026
This issue might be a duplicate of existing issues. Please check:
Error message: JSON Parse error: Unterminated stringerrors #10755: openai/gpt-5.2-codex 'Error message: JSON Parse error: Unterminated string' errors - Similar JSON parsing errors with unterminated strings during normal usageFeel free to ignore if none of these address your specific case.
rekram1-node commentedon Jan 31, 2026
can u provide a prompt to reproduce?
JacquesvanWyk commentedon Jan 31, 2026
Looks like its when its trying large write
⚙ invalid [tool=write, error=Invalid input for tool write: JSON parsing failed: Text: {"content": "# TownHub - Multi-Town Community Platform\n## Technical Specification Document v1.0\n\n---\n\n## 1. EXECUTIVE SUMMARY\n\nProduct Name: TownHub\nPurpose: Hyperlocal platform connecting residents with local businesses, events, and community information across multiple towns.\nTarget Market: South African towns (initially), with global scalability potential.\nRevenue Model: Freemium SaaS (business subscriptions) + transaction fees + advertising\nTech Stack: Laravel API (Backend) + Nuxt.js (Web) + Flutter (Mobile)\n\n---\n\n## 2. USER PERSONAS & USER STORIES\n\n### 2.1 User Types\n\nType A: Resident (Free User)\n- Discovers local businesses, events, and community updates\n- Can browse, search, review, and engage\n- Can post classifieds (limited free listings)\n- Can RSVP to events\n- Can message businesses\n\nType B: Business Owner\n- Basic tier: Free limited listing\n- Premium tier: R299/month - enhanced profile, analytics, unlimited deals\n- Pro tier: R699/month - booking system, priority placement, customer messaging\n- Enterprise: R999/month - white-label, API access, dedicated support\n\nType C: Town Administrator\n- Manages town settings and content moderation\n- Can broadcast emergency notifications\n- Views town analytics\n- Approves/rejects business claims\n\nType D: Super Admin (Platform Owner)\n- Manages all towns\n- User management across platform\n- Revenue analytics\n- System configuration\n\n### 2.2 Detailed User Stories\n\nAs a Resident:\n1. I want to join my town so I can see local content\n2. I want to search for businesses by category and location\n3. I want to view business details including hours, photos, and reviews\n4. I want to leave reviews and ratings for businesses I've visited\n5. I want to see upcoming events in my town and RSVP\n6. I want to buy/sell items locally through classifieds\n7. I want to receive notifications for events I'm attending\n8. I want to save businesses to favorites\n9. I want to share business listings via WhatsApp/SMS\n10. I want to see which businesses are currently open\n\nAs a Business Owner:\n1. I want to claim my business listing\n2. I want to update my business profile with photos, hours, description\n3. I want to create and manage deals/offers\n4. I want to post events to promote to the community\n5. I want to respond to customer reviews\n6. I want to see analytics on profile views and engagement\n7. I want to receive messages from potential customers\n8. I want to manage my subscription and billing\n9. I want to export customer data (with permissions)\n10. I want to integrate booking/appointment scheduling\n\nAs a Town Admin:\n1. I want to moderate community posts and remove inappropriate content\n2. I want to send broadcast notifications to all residents\n3. I want to approve business registrations in my town\n4. I want to view engagement metrics for my town\n5. I want to feature specific businesses or events\n6. I want to configure town-specific settings (categories, rules)\n7. I want to manage town residents and ban problematic users\n8. I want to export town analytics reports\n\n---\n\n## 3. DETAILED FEATURE SPECIFICATIONS\n\n### 3.1 AUTHENTICATION & USER MANAGEMENT\n\n3.1.1 Authentication System\n- Email/password registration with verification\n- Social login: Google, Facebook, Apple\n- Phone number verification (OTP via SMS)\n- JWT token-based authentication (Sanctum)\n- Password reset via email\n- Session management with refresh tokens\n- Rate limiting on login attempts (5 attempts per 15 minutes)\n\n3.1.2 User Profiles\nFields:\n- id (UUID)\n- email (unique, required)\n- phone_number (unique, optional)\n- first_name (required)\n- last_name (required)\n- avatar_url (nullable)\n- bio (text, max 500 chars, nullable)\n- date_of_birth (nullable)\n- gender (enum: male, female, other, prefer_not_to_say, nullable)\n- town_ids (array, many-to-many)\n- current_town_id (FK, nullable)\n- user_type (enum: resident, business_owner, town_admin, super_admin)\n- is_verified (boolean, default: false)\n- email_verified_at (timestamp)\n- phone_verified_at (timestamp)\n- notification_preferences (JSON)\n- privacy_settings (JSON)\n- created_at, updated_at, deleted_at\n\n3.1.3 User Roles & Permissions\nRoles:\n-
resident: Basic browsing and engagement\n-business_owner: Can manage owned businesses\n-town_admin: Can moderate content in assigned towns\n-super_admin: Full platform access\n\nPermissions implemented via Laravel Spatie or custom middleware:\n-view_businesses\n-create_business\n-edit_own_business\n-delete_own_business\n-post_classified\n-create_event\n-moderate_content\n-broadcast_notifications\n-view_analytics\n-manage_subscriptions\n\n### 3.2 TOWN MANAGEMENT\n\n3.2.1 Town Entity\nFields:\n- id (UUID)\n- name (required, unique per country)\n- slug (required, URL-friendly)\n- description (text)\n- country (required, default: ZA)\n- province (required for SA)\n- city/town classification\n- latitude, longitude (for geofencing)\n- radius_km (service area radius)\n- cover_image_url\n- logo_url\n- primary_color, secondary_color (for branding)\n- timezone (default: Africa/Johannesburg)\n- currency (default: ZAR)\n- is_active (boolean)\n- is_featured (boolean)\n- settings (JSON: moderation_rules, posting_limits, etc.)\n- created_by (FK to users)\n- created_at, updated_at\n\n3.2.2 User-Town Relationship\nTable:user_town_memberships\n- id\n- user_id (FK)\n- town_id (FK)\n- role (enum: member, moderator, admin)\n- joined_at (timestamp)\n- is_primary (boolean)\n- notification_enabled (boolean)\n\n3.2.3 Town Joining Logic\n- Users can join multiple towns\n- User selects primary town (default view)\n- Can switch towns via town selector\n- Can discover nearby towns via geolocation\n- Must be approved to join private towns (rare)\n\n### 3.3 BUSINESS DIRECTORY\n\n3.3.1 Business Entity\nFields:\n- id (UUID)\n- name (required, max 255)\n- slug (required, unique per town)\n- description (text, max 5000)\n- short_description (text, max 160, for SEO)\n- town_id (FK, required)\n- owner_user_id (FK, nullable until claimed)\n- category_id (FK, required)\n- subcategory_ids (array of FKs)\n- status (enum: pending, active, suspended, closed)\n- verification_status (enum: unclaimed, pending, verified, rejected)\n\nContact Information:\n- phone_number (required)\n- whatsapp_number (nullable)\n- email (required)\n- website_url (nullable)\n- social_links (JSON: facebook, instagram, twitter, linkedin, tiktok)\n\nLocation:\n- address_line_1 (required)\n- address_line_2 (nullable)\n- suburb (required)\n- postal_code (required)\n- latitude (required)\n- longitude (required)\n- google_place_id (nullable)\n\nBusiness Details:\n- business_type (enum: physical, online, both)\n- year_established (nullable)\n- employee_count (enum: solo, 2-5, 6-10, 11-25, 26-50, 50+)\n- tags (array of strings, max 10)\n\nMedia:\n- logo_url (nullable)\n- cover_image_url (nullable)\n- gallery_images (array of URLs, max 20)\n-.Error message: JSON Parse error: Unterminated string]
shmish111 commentedon Feb 1, 2026
I had this issue and it's a real PITA because everything stops and it seems opencode doesn't realise. If I tell it the error and tell it to use a sub agent then it will eventually work. I assume it sees the error output from the sub agent but not from itself.
rekram1-node commentedon Feb 2, 2026
make sure you are on latest, if you installed via brew make sure you are using correct tap:
brew install anomalyco/tap/opencodeThis was fixed in 1.1.41
qingmo commentedon Feb 6, 2026
brew info opencode
==> opencode ✔: stable 1.1.50 (bottled)
the problem still appeared when write into file with a large content which are produced by ai model.
temp solution
⚙ invalid [tool=write, error=Invalid input for tool write: JSON parsing failed: Text: {"filePath": "xxxx.md".
Error message: JSON Parse error: Expected '}']
▣ Build · claude-sonnet · 2m 39s
Promot:Do not write all at once; write in batches to avoid writing issues.
it works