{"record":{"id":"232fb76b8ad52c14","repo":"Freika/dawarich","slug":"maps-v2-unknown-entity-type-for-delete","errorCode":null,"errorMessage":"[Maps V2] Unknown entity type for delete:","messagePattern":"\\[Maps V2\\] Unknown entity type for delete:","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"app/javascript/controllers/maps/maplibre_controller.js","lineNumber":1807,"sourceCode":"  }\n\n  /**\n   * Handle delete action from info display\n   */\n  handleDelete(event) {\n    const button = event.currentTarget\n    const id = button.dataset.id\n    const entityType = button.dataset.entityType\n\n    switch (entityType) {\n      case \"area\":\n        this.deleteArea(id)\n        break\n      case \"point\":\n        this.deletePoint(id)\n        break\n      default:\n        console.warn(\"[Maps V2] Unknown entity type for delete:\", entityType)\n    }\n  }\n\n  /**\n   * Open visit edit modal\n   */\n  async openVisitModal(visitId) {\n    try {\n      // Fetch visit details\n      const response = await fetch(`/api/v1/visits/${visitId}`, {\n        headers: {\n          Authorization: `Bearer ${this.apiKeyValue}`,\n          \"Content-Type\": \"application/json\",\n        },\n      })\n\n      if (!response.ok) {\n        throw new Error(`Failed to fetch visit: ${response.status}`)","sourceCodeStart":1789,"sourceCodeEnd":1825,"githubUrl":"https://github.com/Freika/dawarich/blob/97fad417c5a11b0eb11157890635e015723a2e97/app/javascript/controllers/maps/maplibre_controller.js#L1789-L1825","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Check the rendered delete button in DevTools and set data-entity-type to exactly \"area\" or \"point\" in the popup template that produced it.","If a new deletable entity type exists, add its case to the switch in handleDelete (app/javascript/controllers/maps/maplibre_controller.js:1799).","Audit popup templates for copy-pasted edit buttons (visit/place) wired to the delete action and fix the action/entity-type pairing."],"exampleFix":"// before\n// <button data-id=\"${p.id}\" data-entity-type=\"visit\" data-action=\"click->maps--maplibre#handleDelete\">Delete</button>\n\n// after\n// <button data-id=\"${p.id}\" data-entity-type=\"point\" data-action=\"click->maps--maplibre#handleDelete\">Delete</button>","handlingStrategy":"type-guard","validationCode":"const DELETABLE_TYPES = new Set([\"area\", \"point\"])\nconst ok = DELETABLE_TYPES.has(button.dataset.entityType)","typeGuard":"const isDeletableEntityType = (t) => t === \"area\" || t === \"point\"","tryCatchPattern":null,"preventionTips":["Keep edit (visit/place) and delete (area/point) type sets as named constants next to each other so the asymmetry is visible.","Add a lint/grep check that popup buttons wired to handleDelete never use visit/place values."],"tags":["stimulus","maplibre","dataset-attribute","switch-default"],"backgroundTag":"invalid-data-attribute","analyzedSha":"97fad417c5a11b0eb11157890635e015723a2e97","analyzedAt":"2026-08-21T17:04:17.778Z","schemaVersion":2},"datasetVersion":"2026-08-21T18:17:14.833Z"}