grafana/grafana · error · Error

Element "${elementName}" not found in the dashboard

Error message

Element "${elementName}" not found in the dashboard

What it means

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.

Source

Thrown at public/app/features/dashboard-scene/mutation-api/commands/movePanel.ts:123

  name: 'MOVE_PANEL',
  description: payloads.movePanel.description ?? '',

  payloadSchema: payloads.movePanel,
  permission: requiresNewDashboardLayouts,
  readOnly: false,

  handler: async (payload, context) => {
    const { scene } = context;
    enterEditModeIfNeeded(scene);

    try {
      const { element, toParent } = payload;
      const elementName = element.name;
      const warnings: string[] = [];

      const panelId = scene.serializer.getPanelIdForElement(elementName);
      if (panelId === undefined) {
        throw new Error(`Element "${elementName}" not found in the dashboard`);
      }

      const expectedKey = getVizPanelKeyForPanelId(panelId);
      const allPanels = scene.state.body.getVizPanels();
      const vizPanel = allPanels.find((p) => p.state.key === expectedKey);
      if (!vizPanel) {
        throw new Error(`Panel with ID ${panelId} (element "${elementName}") not found in the layout`);
      }

      const effectivePosition = resolveEffectivePosition(payload, warnings);

      if (!toParent) {
        const currentLayout = getLayoutManagerFor(vizPanel);
        const isAutoGrid = currentLayout instanceof AutoGridLayoutManager;
        const isDefaultGrid = currentLayout instanceof DefaultGridLayoutManager;

        emitLayoutItemKindWarnings(payload.layoutItem?.kind, isAutoGrid, isDefaultGrid, warnings);

View on GitHub (pinned to ae3104e369)

Solutions

  1. Fetch the dashboard and read the actual element names from the elements map before issuing MOVE_PANEL.
  2. Use the exact element.name string returned by GET_DASHBOARD/elements (case-sensitive).
  3. If the panel was deleted, remove it from the caller's tracking rather than moving it.
  4. Distinguish element names from panel titles and panel ids — only element.name is accepted here.

Example fix

// before - guessing the element name
await mutate('MOVE_PANEL', { element: { name: 'My Panel Title' }, toParent: '/rows/0' });

// after - use the real element name from the dashboard
const { elements } = await query('GET_DASHBOARD');
const name = Object.keys(elements).find((n) => elements[n].title === 'My Panel Title');
await mutate('MOVE_PANEL', { element: { name }, toParent: '/rows/0' });
Defensive patterns

Strategy: validation

Validate before calling

// Confirm the element name exists before MOVE_PANEL.
const id = scene.serializer.getPanelIdForElement(elementName);
if (id === undefined) {
  return { skip: true, reason: `Element '${elementName}' not in the elements map` };
}

Type guard

function elementExists(scene: DashboardScene, name: string): boolean {
  return scene.serializer.getPanelIdForElement(name) !== undefined;
}

Try / catch

const res = await mutate('MOVE_PANEL', payload);
if (!res.success && /not found in the dashboard/.test(res.error)) {
  // re-fetch GET_DASHBOARD and use a valid element name
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of grafana/grafana@ae3104e369 (2026-08-12). Data as JSON: /api/errors/5d5f20d3b1666a57. Report an issue: GitHub.