Skip to content

fix: Skip unsupported KML NetworkLinks instead of failing the whole import#53

Merged
njakobsen merged 1 commit into
masterfrom
fix/skip-unsupported-kml-network-links
Jun 4, 2026
Merged

fix: Skip unsupported KML NetworkLinks instead of failing the whole import#53
njakobsen merged 1 commit into
masterfrom
fix/skip-unsupported-kml-network-links

Conversation

@njakobsen
Copy link
Copy Markdown
Member

@njakobsen njakobsen commented Jun 4, 2026

Problem

A KMZ exported from Google Earth that mixes embedded placemark geometry with <NetworkLink> elements (links to remotely hosted layers) failed to import entirely, surfacing only a generic "Unable to import features due to a map data error." Importers::KML#kml_document raised ImportError on the first NetworkLink it found.

Reported by Michelle from Ktunaxa: her BC Hydro Facilities IVMP.kmz contains 133 importable points + polygons plus 2 NetworkLinks (Substations, Mobile Radio Repeaters), and imported nothing.

Change

  • Importers::KML now strips NetworkLink nodes and records a non-fatal warning naming the skipped layers, then imports the embedded geometry.
  • New warnings accumulator on Importers::Base; aggregated in update_features! and persisted to spatial_processing_status_cache (read via feature_update_warnings) so they survive job completion (successful Delayed::Jobs are deleted).
  • Each warning is prefixed with its importer's source_identifier (e.g. archive.zip/layer.kml), so a multi-file / multi-source import identifies which file the warning belongs to.
  • A NetworkLink-only file still fails, but now via EmptyImportError whose message explains which layers were skipped.

This preserves the original 2023 intent (fail loud when a file has nothing importable) while no longer discarding valid geometry.

Validation

  • Full spec suite green (added importer + update_features! coverage, a hybrid fixture, and a multi-file attribution test).
  • Reproduced end-to-end against the real importer under the Ktunaxa deployment: her KMZ now imports all 133 features (112 points, 21 polygons) and persists the (file-attributed) warning. (Validated on the equivalent 3.9.x build, since the consuming connect_engine pins ~> 3.9.0; the NetworkLink code path is identical on master.)

Downstream (toward Stolo/SC)

connect_engine surfaces these via a companion PR (specific reason on failure + warning notice on partial import). On a Referral / ReferralSubmission the warning renders as an in-page notice via feature_update_notifications, since those models import the footprint directly (include UploadedFileMapLayer). To reach deployments, CE's spatial_features pin needs to allow 3.10.2, then CE + SC bumps follow.

🤖 Generated with Claude Code

…mport

A KMZ exported from Google Earth that mixes embedded placemark geometry with `<NetworkLink>` elements (references to remotely hosted layers) failed to import entirely, surfacing only a generic map data error. `SpatialFeatures::Importers::KML#kml_document` raised `ImportError` the moment it encountered any `NetworkLink`, so the BC Hydro Facilities IVMP KMZ reported by Michelle from Ktunaxa — 133 importable points and polygons alongside two NetworkLinks — produced zero features.

Instead of raising `ImportError` when a `NetworkLink` is present, the importer now removes the NetworkLink nodes and records a non-fatal warning naming the skipped layers before importing the embedded geometry. Warnings flow through a new `warnings` accumulator on `Importers::Base`, are aggregated in `update_features!`, and are persisted to `spatial_processing_status_cache` (readable via `feature_update_warnings`) so they survive job completion, since successful `Delayed::Job`s are deleted and cannot be read back. A file containing only NetworkLinks still fails, but now via an `EmptyImportError` whose message names the skipped layers rather than a bare "no features found".

Each warning is prefixed with its importer's `source_identifier` (e.g. `archive.zip/layer.kml`), so a multi-file or multi-source import makes clear which file the warning belongs to.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@njakobsen njakobsen force-pushed the fix/skip-unsupported-kml-network-links branch from 6c55854 to f4272be Compare June 4, 2026 07:11
@njakobsen njakobsen merged commit 74da868 into master Jun 4, 2026
2 checks passed
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