-
Notifications
You must be signed in to change notification settings - Fork 0
Description
Severity
P0 — Runtime crash
Description
In `src/utils/index.ts:47`:
```ts
return (metadata?.id ?? feature.properties?.id).toString()
```
If a feature has neither `metadata.id` nor `properties.id`, the expression evaluates to `undefined.toString()`, throwing an uncaught `TypeError`. Since `getFeatureId` is called in the core render loop (`renderCustom`), a single feature without an id crashes the entire map rendering.
Reproduction
Any GeoJSON feature without `properties.id` and without `properties.metadata.id` will trigger this.
Suggested Fix
Add an explicit guard:
```ts
const id = metadata?.id ?? feature.properties?.id
if (id == null)
throw new Error('Feature is missing an "id" in properties or metadata.')
return id.toString()
```
This converts a confusing `TypeError` into a meaningful error message. Alternatively, consider falling back to `feature.id` (the GeoJSON spec-level id) before throwing.
Files
- `src/utils/index.ts:47`