Skip to content

fix: settings page crash on .map() of undefined#1

Merged
fdatoo merged 4 commits intomainfrom
fix/settings-page-map-crash
Apr 30, 2026
Merged

fix: settings page crash on .map() of undefined#1
fdatoo merged 4 commits intomainfrom
fix/settings-page-map-crash

Conversation

@fdatoo
Copy link
Copy Markdown
Owner

@fdatoo fdatoo commented Apr 30, 2026

Summary

  • The settings page was crashing with TypeError: Cannot read properties of undefined (reading 'map') because the API returned global_marketplaces_json/global_plugins_json (raw JSON strings) while the TypeScript client expected global_marketplaces/global_plugins (parsed arrays)
  • setMarketplaces(undefined) put undefined into state, then ChipInput crashed calling .map() on it
  • Saves were also silently broken in the other direction — the PATCH handler expected _json-suffixed string fields but the client sent arrays

Changes

  • json/settings.gleam: encoder now parses the stored JSON strings and emits proper string[] arrays under the correct field names
  • handlers/settings.gleam: PATCH decoder now accepts List(String) arrays and JSON-encodes them before persisting

Test plan

  • Open the settings page — it should load without crashing
  • Add/remove a plugin marketplace or plugin chip and save — values should persist across reload
  • Verify MCP server list still renders correctly

🤖 Generated with Claude Code

fdatoo and others added 4 commits April 30, 2026 10:00
…gins

The server was emitting global_marketplaces_json/global_plugins_json
(raw JSON strings) but the TypeScript client expected global_marketplaces/
global_plugins (parsed arrays). setMarketplaces(undefined) then caused
ChipInput to call .map() on undefined.

Fix both directions:
- GET encoder now parses the stored JSON strings and emits proper arrays
  under the correct field names
- PATCH handler now accepts arrays and JSON-encodes them before DB storage

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@fdatoo fdatoo merged commit 9c036aa into main Apr 30, 2026
5 checks passed
@fdatoo fdatoo deleted the fix/settings-page-map-crash branch April 30, 2026 12:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant