Freika/dawarich · warning

[Maps V2] Unknown entity type:

Error message

[Maps V2] Unknown entity type:

What it means

This console.warn fires in the Maps V2 info-display edit handler (handleEdit) when a clicked edit button carries a data-entity-type value that is neither "visit" nor "place". The handler dispatches modals purely off the button's dataset, so an absent or unrecognized data-entity-type silently no-ops with only a warning. It is a Stimulus dataset-contract violation between the popup template that renders the button and this switch statement.

Source

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

  }

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

    switch (entityType) {
      case "visit":
        this.openVisitModal(id)
        break
      case "place":
        this.openPlaceEditModal(id)
        break
      default:
        console.warn("[Maps V2] Unknown entity type:", entityType)
    }
  }

  /**
   * 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

View on GitHub (pinned to 97fad417c5)

Solutions

  1. Inspect the clicked button in DevTools and confirm data-entity-type is present and exactly "visit" or "place"; fix the popup template that renders it (search for data-entity-type in the info-display/popup partials).
  2. If a legitimate new entity type was introduced, add its case to the switch in handleEdit (app/javascript/controllers/maps/maplibre_controller.js:1781) alongside visit/place.
  3. Rename the attribute consistently if it was misspelled in markup (dataset.entityType maps only to data-entity-type).

Example fix

// before (popup template)
// <button data-id="<%= visit.id %>" data-action="click->maps--maplibre#handleEdit">Edit</button>

// after
// <button data-id="<%= visit.id %>" data-entity-type="visit" data-action="click->maps--maplibre#handleEdit">Edit</button>
Defensive patterns

Strategy: type-guard

Validate before calling

const EDITABLE_TYPES = new Set(["visit", "place"])
const ok = EDITABLE_TYPES.has(button.dataset.entityType)

Type guard

const isEditableEntityType = (t) => t === "visit" || t === "place"

Prevention

When it happens

Trigger: Clicking an Edit button in a map info popup where the template omitted data-entity-type, misspelled it (e.g. data-entity_type), or passed a type like "point"/"area" that handleEdit does not support (those belong to handleDelete's switch). Also reproduced when a new entity type is added to the popup renderer without extending this switch.

Common situations: Template refactors that drop or rename the dataset attribute; adding a new clickable entity (e.g. notes) to the info display without updating handleEdit; copy-pasting the delete button markup (area/point) into an edit slot; HAML/ERB conditionals that render the button without the attribute for some entity kinds.

Related errors


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