{"record":{"id":"b4a3af16fbcada7c","repo":"chartjs/Chart.js","slug":"id-is-not-a-registered-type","errorCode":null,"errorMessage":"\"${id}\" is not a registered ${type}.","messagePattern":"\"(.+?)\" is not a registered (.+?)\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"critical","filePath":"src/core/core.registry.js","lineNumber":178,"sourceCode":"\t */\n  _getRegistryForType(type) {\n    for (let i = 0; i < this._typedRegistries.length; i++) {\n      const reg = this._typedRegistries[i];\n      if (reg.isForType(type)) {\n        return reg;\n      }\n    }\n    // plugins is the fallback registry\n    return this.plugins;\n  }\n\n  /**\n\t * @private\n\t */\n  _get(id, typedRegistry, type) {\n    const item = typedRegistry.get(id);\n    if (item === undefined) {\n      throw new Error('\"' + id + '\" is not a registered ' + type + '.');\n    }\n    return item;\n  }\n\n}\n\n// singleton instance\nexport default /* #__PURE__ */ new Registry();\n","sourceCodeStart":160,"sourceCodeEnd":187,"githubUrl":"https://github.com/chartjs/Chart.js/blob/cb02e1d207bd4c4c40b20c259017f85f26f1e30a/src/core/core.registry.js#L160-L187","documentation":"Registry._get(id, typedRegistry, type) looks up an item by id in the typed registry (scales, elements, controllers, plugins) and throws when the id is absent. It is called when resolving a component by id at render time, e.g. a dataset's `type`, a scale's `type`, or a plugin id in the config. The `type` in the message is the registry category (e.g. 'scale', 'controller', 'element').","triggerScenarios":"Using a chart type or dataset type whose controller is not registered (e.g. 'bubble' or 'scatter' under the bare 'chart.js' import that registers nothing); referencing scale type 'time' without registering TimeScale; listing a plugin id in options.plugins that was never registered; importing from 'chart.js' (manual) instead of 'chart.js/auto'.","commonSituations":"Bundle-size optimization via manual tree-shaken imports that omit a needed controller/scale/element; upgrading and a previously auto-registered component is no longer pulled in; typos in type strings ('lIne'); SSR builds where the registration side-effect import was stripped.","solutions":["Switch to `import Chart from 'chart.js/auto'` to auto-register all bundled components.","Or explicitly register the missing component: `import { Chart, LineController, LinearScale, PointElement, LineElement } from 'chart.js'; Chart.register(LineController, LinearScale, PointElement, LineElement);`.","Verify the type string matches a registered id exactly (case-sensitive).","Check that registration side-effect imports are not dropped by the bundler (mark the module as having sideEffects, or import in the entry)."],"exampleFix":"// before\nimport { Chart } from 'chart.js';\nnew Chart(ctx, { type: 'line', data }); // 'line' controller not registered -> throws\n\n// after\nimport { Chart, LineController, LinearScale, PointElement, LineElement, CategoryScale } from 'chart.js';\nChart.register(LineController, LinearScale, PointElement, LineElement, CategoryScale);\nnew Chart(ctx, { type: 'line', data });","handlingStrategy":"validation","validationCode":"// Verify a component id is registered before relying on it.\nimport { Chart } from 'chart.js';\n\nfunction ensureRegistered(type, id) {\n  // Chart.registry exposes get(id) for registered items per category\n  try {\n    const item = Chart.registry.get(id);\n    if (!item) throw new Error(`'${id}' is not a registered ${type}.`);\n    return item;\n  } catch (e) {\n    throw new Error(`Register '${id}' (${type}) before use. Use 'chart.js/auto' or Chart.register(...).`);\n  }\n}\nensureRegistered('scale', 'linear');\nensureRegistered('controller', 'line');","typeGuard":"// Type helper to constrain type strings to a known registered set.\nimport type { ChartType, ScaleType } from 'chart.js';\nfunction asKnownChartType(t: string): t is ChartType {\n  return ['bar', 'line', 'scatter', 'bubble', 'pie', 'doughnut', 'polarArea', 'radar'].includes(t);\n}","tryCatchPattern":null,"preventionTips":["Use 'chart.js/auto' unless you are explicitly tree-shaking, and then register every component you reference.","Add an integration test that renders each chart/scale/plugin type your app uses.","Keep a single module that imports 'chart.js' and registers all needed components, imported once from the app entry.","Treat typos in type strings as a build-time risk: validate against a whitelist."],"tags":["registry","tree-shaking","configuration","setup"],"backgroundTag":null,"analyzedSha":"cb02e1d207bd4c4c40b20c259017f85f26f1e30a","analyzedAt":"2026-08-12T23:38:10.965Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}