{"record":{"id":"5d5f20d3b1666a57","repo":"grafana/grafana","slug":"element-elementname-not-found-in-the-dashboar","errorCode":null,"errorMessage":"Element \"${elementName}\" not found in the dashboard","messagePattern":"Element \"(.+?)\" not found in the dashboard","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"public/app/features/dashboard-scene/mutation-api/commands/movePanel.ts","lineNumber":123,"sourceCode":"  name: 'MOVE_PANEL',\n  description: payloads.movePanel.description ?? '',\n\n  payloadSchema: payloads.movePanel,\n  permission: requiresNewDashboardLayouts,\n  readOnly: false,\n\n  handler: async (payload, context) => {\n    const { scene } = context;\n    enterEditModeIfNeeded(scene);\n\n    try {\n      const { element, toParent } = payload;\n      const elementName = element.name;\n      const warnings: string[] = [];\n\n      const panelId = scene.serializer.getPanelIdForElement(elementName);\n      if (panelId === undefined) {\n        throw new Error(`Element \"${elementName}\" not found in the dashboard`);\n      }\n\n      const expectedKey = getVizPanelKeyForPanelId(panelId);\n      const allPanels = scene.state.body.getVizPanels();\n      const vizPanel = allPanels.find((p) => p.state.key === expectedKey);\n      if (!vizPanel) {\n        throw new Error(`Panel with ID ${panelId} (element \"${elementName}\") not found in the layout`);\n      }\n\n      const effectivePosition = resolveEffectivePosition(payload, warnings);\n\n      if (!toParent) {\n        const currentLayout = getLayoutManagerFor(vizPanel);\n        const isAutoGrid = currentLayout instanceof AutoGridLayoutManager;\n        const isDefaultGrid = currentLayout instanceof DefaultGridLayoutManager;\n\n        emitLayoutItemKindWarnings(payload.layoutItem?.kind, isAutoGrid, isDefaultGrid, warnings);\n","sourceCodeStart":105,"sourceCodeEnd":141,"githubUrl":"https://github.com/grafana/grafana/blob/ae3104e3690e28e72c8f0c97efc12647a70f75c3/public/app/features/dashboard-scene/mutation-api/commands/movePanel.ts#L105-L141","documentation":"Thrown by MOVE_PANEL when scene.serializer.getPanelIdForElement(elementName) returns undefined, meaning the supplied element name is not present in the dashboard's elements map. The elements map is the canonical name→panel registry; an unknown name means there is no panel to move.","triggerScenarios":"Calling MOVE_PANEL with element.name that doesn't match any key in the dashboard's elements map. Common with stale/hard-coded names, typos, names from a different dashboard, or after the panel was deleted but the caller cached the old name.","commonSituations":"AI/automation using a panel title or id instead of the element name; caller cached element names from an older revision; rename/delete left the caller out of sync; cross-dashboard name assumption.","solutions":["Fetch the dashboard and read the actual element names from the elements map before issuing MOVE_PANEL.","Use the exact element.name string returned by GET_DASHBOARD/elements (case-sensitive).","If the panel was deleted, remove it from the caller's tracking rather than moving it.","Distinguish element names from panel titles and panel ids — only element.name is accepted here."],"exampleFix":"// before - guessing the element name\nawait mutate('MOVE_PANEL', { element: { name: 'My Panel Title' }, toParent: '/rows/0' });\n\n// after - use the real element name from the dashboard\nconst { elements } = await query('GET_DASHBOARD');\nconst name = Object.keys(elements).find((n) => elements[n].title === 'My Panel Title');\nawait mutate('MOVE_PANEL', { element: { name }, toParent: '/rows/0' });","handlingStrategy":"validation","validationCode":"// Confirm the element name exists before MOVE_PANEL.\nconst id = scene.serializer.getPanelIdForElement(elementName);\nif (id === undefined) {\n  return { skip: true, reason: `Element '${elementName}' not in the elements map` };\n}","typeGuard":"function elementExists(scene: DashboardScene, name: string): boolean {\n  return scene.serializer.getPanelIdForElement(name) !== undefined;\n}","tryCatchPattern":"const res = await mutate('MOVE_PANEL', payload);\nif (!res.success && /not found in the dashboard/.test(res.error)) {\n  // re-fetch GET_DASHBOARD and use a valid element name\n}","preventionTips":["Read element names from the dashboard's elements map; don't guess from titles or ids.","Treat element names as case-sensitive exact strings.","After deletions, prune stale names from caller-side tracking."],"tags":["panels","move-panel","dashboard-scene","mutation-api","not-found"],"backgroundTag":null,"analyzedSha":"ae3104e3690e28e72c8f0c97efc12647a70f75c3","analyzedAt":"2026-08-12T12:48:38.752Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}