plotly/plotly.js · warning
Variable '${key}' in ${name} could not be found! Please veri
Error message
Variable '${key}' in ${name} could not be found! Please verify that the template is correct. Using value: '${fallbackValue}'. What it means
plotly.js's internal template-string helper substitutes placeholders like %{x} or ${key} in attribute strings. When a referenced variable is undefined, it warns that the variable could not be found and falls back to a fallback value (either the raw match or a caller-supplied fallback). This indicates a malformed or over-generic template rather than a fatal error.
Source
Thrown at src/lib/index.js:1143
if (!obj) continue;
if (obj.hasOwnProperty(key)) {
value = obj[key];
break;
}
if (!SIMPLE_PROPERTY_REGEX.test(key)) {
// true here means don't convert null to undefined
value = lib.nestedProperty(obj, key).get(true);
}
if (value !== undefined) break;
}
}
if (value === undefined) {
const { count, max, name } = opts;
const fallbackValue = fallback === false ? match : fallback;
if (count < max) {
lib.warn(
[
`Variable '${key}' in ${name} could not be found!`,
'Please verify that the template is correct.',
`Using value: '${fallbackValue}'.`
].join(' ')
);
}
if (count === max) lib.warn(`Too many '${name}' warnings - additional warnings will be suppressed.`);
opts.count++;
return fallbackValue;
}
if (parsedOp === '*') value *= parsedNumber;
if (parsedOp === '/') value /= parsedNumber;
if (format) {
var fmt;View on GitHub (pinned to 1d090e0b5f)
Solutions
- Verify the template key spelling matches a property present in the supplied object.
- Provide the missing variable in the data object passed to the templater.
- Pass a sensible `fallback` option so the substitution uses a known value instead of the raw placeholder.
- If this comes from plotly internals (attribute text interpolation), check that the trace/layout attribute value you set matches the expected format.
Example fix
// before
templater('Hello ${name}!', {nmae: 'Ada'});
// after
templater('Hello ${name}!', {name: 'Ada'}); Defensive patterns
Strategy: validation
Validate before calling
function validateTemplateVars(template, data) {
const missing = [...template.matchAll(/\$\{(\w+)\}/g)]
.map(m => m[1])
.filter(k => data[k] === undefined);
if (missing.length) throw new Error(`Missing template vars: ${missing}`);
} Type guard
function hasVar(data, key) { return typeof data === 'object' && data !== null && data[key] !== undefined; } Prevention
- Centralize template strings and unit-test them against their expected data shapes.
- Provide defaults for optional fields before templating (value ?? fallback).
- Pass a fallback option to the templater for optional variables.
When it happens
Trigger: Calling the templating helper (src/lib/index.js templater) with a string containing a placeholder key that is absent from the provided data object, e.g. templater('Value: ${foo}', {bar: 1}).
Common situations: Typos in template keys, data objects with optional fields left undefined, renaming an object property without updating the template, or localized/custom attribute strings referencing removed variables.
Related errors
AI-assisted analysis of plotly/plotly.js@1d090e0b5f (2026-09-02).
Data as JSON: /api/errors/d36197eb5618ec46.
Report an issue: GitHub.