Skip to content

fix(GeolocationEditor): handle missing geo-data files gracefully#438

Open
Laqoore wants to merge 1 commit into
seatable:masterfrom
Laqoore:fix/geo-data-fetch-null-safety
Open

fix(GeolocationEditor): handle missing geo-data files gracefully#438
Laqoore wants to merge 1 commit into
seatable:masterfrom
Laqoore:fix/geo-data-fetch-null-safety

Conversation

@Laqoore

@Laqoore Laqoore commented May 27, 2026

Copy link
Copy Markdown

Problem

In SeaTable external apps (Universal Apps), geo-data JSON files are fetched from a path derived from mediaUrl, which in the external app context resolves to the app's own URL (e.g. /external-apps/<uuid>/geo-data/). These files don't exist there, causing 404 errors.

404s observed:

  • /external-apps/<uuid>/geo-data/en-region-location.json → 404
  • /external-apps/<uuid>/geo-data/cn-location.json → 404
  • /external-apps/<uuid>/geo-data/cn-region-location.json → 404

This produces white screens with:

TypeError: Cannot read properties of undefined (reading "includes")
  at Array.filter
  at DE.render

Closes #437

Root Causes

  1. getLocationData/getCountryData: The local fallback fetch('./geo-data/...') has no .catch(), so when both fetches fail the returned promise rejects. Component .then() handlers never run.

  2. getCountryData: const { mediaUrl = '', server = '' } = config; throws if config is null/undefined (unlike getLocationData which already uses config || {}).

  3. PC editors (ProvinceEditor, ProvinceCityEditor, LocationEditor): No .catch() on getData() call; this.locations.children accessed without null guard; province.name.includes(...) called without checking province.name is defined.

  4. MB editors: Missing .catch() handlers and null guards in transLocationData/transCountryData and functional components.

Fix

  • Both fetch chains always resolve: fallback adds .catch(() => null) so the outer .then(res => { const data = res || {}; }) always runs
  • config || {} added to getCountryData
  • All getData().then(data => ...) calls get .catch(() => setLoadingFalse)
  • (this.locations.children || []) and province.name && guards added throughout
  • transLocationData(null) returns [] instead of crashing on .children

When geo-data JSON files are unavailable (e.g. 404 in SeaTable external
apps), both primary and fallback fetch chains now always resolve rather
than reject, preventing unhandled promise rejections that left the
editor stuck in an infinite loading state or caused TypeError crashes
in render methods.

Changes:
- getLocationData / getCountryData: add .catch(() => null) to the local
  fallback so the promise always resolves; fix missing `|| {}` guard on
  config destructuring in getCountryData
- transLocationData / transCountryData (mb-editor): guard against null/
  undefined input, return [] instead of crashing on null.children
- ProvinceEditor, ProvinceCityEditor, LocationEditor (pc + mb): add
  .catch() handlers so isLoadingData is cleared on fetch failure, and
  guard .children access with || [] to prevent 'Cannot read properties
  of undefined' crashes
- initLocationSelecting: guard .children with || [] and add name truthy
  check before calling .includes() so corrupt geo-data entries do not
  crash the editor

Co-Authored-By: Paperclip <noreply@paperclip.ing>
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.

fix: GeolocationEditor crashes when geo-data files return 404 (unhandled promise rejection + missing null guards)

1 participant