Freika/dawarich · warning

[Maps V2] Unknown entity type for delete:

Error message

[Maps V2] Unknown entity type for delete:

What it means

This console.warn fires in the Maps V2 info-display delete handler (handleDelete) when a clicked delete button's data-entity-type is neither "area" nor "point". Note the asymmetry with handleEdit: the edit switch accepts visit/place while the delete switch accepts area/point, so wiring the wrong action or copying the wrong button template trips this immediately. The click is silently dropped apart from the warning.

Source

Thrown at app/javascript/controllers/maps/maplibre_controller.js:1807

  }

  /**
   * Handle delete action from info display
   */
  handleDelete(event) {
    const button = event.currentTarget
    const id = button.dataset.id
    const entityType = button.dataset.entityType

    switch (entityType) {
      case "area":
        this.deleteArea(id)
        break
      case "point":
        this.deletePoint(id)
        break
      default:
        console.warn("[Maps V2] Unknown entity type for delete:", entityType)
    }
  }

  /**
   * Open visit edit modal
   */
  async openVisitModal(visitId) {
    try {
      // Fetch visit details
      const response = await fetch(`/api/v1/visits/${visitId}`, {
        headers: {
          Authorization: `Bearer ${this.apiKeyValue}`,
          "Content-Type": "application/json",
        },
      })

      if (!response.ok) {
        throw new Error(`Failed to fetch visit: ${response.status}`)

View on GitHub (pinned to 97fad417c5)

Solutions

  1. Check the rendered delete button in DevTools and set data-entity-type to exactly "area" or "point" in the popup template that produced it.
  2. If a new deletable entity type exists, add its case to the switch in handleDelete (app/javascript/controllers/maps/maplibre_controller.js:1799).
  3. Audit popup templates for copy-pasted edit buttons (visit/place) wired to the delete action and fix the action/entity-type pairing.

Example fix

// before
// <button data-id="${p.id}" data-entity-type="visit" data-action="click->maps--maplibre#handleDelete">Delete</button>

// after
// <button data-id="${p.id}" data-entity-type="point" data-action="click->maps--maplibre#handleDelete">Delete</button>
Defensive patterns

Strategy: type-guard

Validate before calling

const DELETABLE_TYPES = new Set(["area", "point"])
const ok = DELETABLE_TYPES.has(button.dataset.entityType)

Type guard

const isDeletableEntityType = (t) => t === "area" || t === "point"

Prevention

When it happens

Trigger: Clicking a Delete button whose template lacks data-entity-type, or carries "visit"/"place" (values valid only for the edit switch). Any new deletable entity type added to the info display without a matching case in this switch also triggers it.

Common situations: Reusing the edit button markup for delete (or vice versa) during popup template work; refactor renames of the entity-type vocabulary; conditionally rendered buttons that omit the attribute for certain layers.

Related errors


AI-assisted analysis of Freika/dawarich@97fad417c5 (2026-08-21). Data as JSON: /api/errors/232fb76b8ad52c14. Report an issue: GitHub.