fix: do not fail when trying to read metadata of a missing geojson (#2592)

Some geojson have been removed by mistake time ago (cf #1003), when
someone tries to load a map referencing them, it was until recently just
showing an error message, but since recently we try to get the metadata
from it, and this will crash.
This commit is contained in:
Yohan Boniface 2025-03-28 15:28:13 +01:00 committed by GitHub
commit 75457b6d5c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -526,7 +526,10 @@ class DataLayer(NamedModel):
metadata = self.settings metadata = self.settings
if not metadata: if not metadata:
# Fallback to file for old datalayers. # Fallback to file for old datalayers.
try:
data = json.loads(self.geojson.read().decode()) data = json.loads(self.geojson.read().decode())
except FileNotFoundError:
data = {}
metadata = data.get("_umap_options") metadata = data.get("_umap_options")
if not metadata: if not metadata:
metadata = { metadata = {