{"record":{"id":"ec937cec3584987c","repo":"Freika/dawarich","slug":"maps-v2-unknown-entity-type","errorCode":null,"errorMessage":"[Maps V2] Unknown entity type:","messagePattern":"\\[Maps V2\\] Unknown entity type:","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"app/javascript/controllers/maps/maplibre_controller.js","lineNumber":1787,"sourceCode":"  }\n\n  /**\n   * Handle edit action from info display\n   */\n  handleEdit(event) {\n    const button = event.currentTarget\n    const id = button.dataset.id\n    const entityType = button.dataset.entityType\n\n    switch (entityType) {\n      case \"visit\":\n        this.openVisitModal(id)\n        break\n      case \"place\":\n        this.openPlaceEditModal(id)\n        break\n      default:\n        console.warn(\"[Maps V2] Unknown entity type:\", entityType)\n    }\n  }\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","sourceCodeStart":1769,"sourceCodeEnd":1805,"githubUrl":"https://github.com/Freika/dawarich/blob/97fad417c5a11b0eb11157890635e015723a2e97/app/javascript/controllers/maps/maplibre_controller.js#L1769-L1805","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["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).","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.","Rename the attribute consistently if it was misspelled in markup (dataset.entityType maps only to data-entity-type)."],"exampleFix":"// before (popup template)\n// <button data-id=\"<%= visit.id %>\" data-action=\"click->maps--maplibre#handleEdit\">Edit</button>\n\n// after\n// <button data-id=\"<%= visit.id %>\" data-entity-type=\"visit\" data-action=\"click->maps--maplibre#handleEdit\">Edit</button>","handlingStrategy":"type-guard","validationCode":"const EDITABLE_TYPES = new Set([\"visit\", \"place\"])\nconst ok = EDITABLE_TYPES.has(button.dataset.entityType)","typeGuard":"const isEditableEntityType = (t) => t === \"visit\" || t === \"place\"","tryCatchPattern":null,"preventionTips":["Define the entity-type vocabulary in one shared constant and use it in both the popup template renderer and the switch statements.","Render the data-entity-type attribute unconditionally in popup button templates.","In the default case, log button.outerHTML to pinpoint the offending template immediately."],"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"}