{"record":{"id":"5fe29d9a3bff786e","repo":"gatsbyjs/gatsby","slug":"a-languageextension-needs-to-be-defined-as-an-obje","errorCode":null,"errorMessage":"A languageExtension needs to be defined as an object. Given config is not valid: ${JSON.stringify(languageExtension)}","messagePattern":"A languageExtension needs to be defined as an object\\. Given config is not valid: (.+?)","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/gatsby-remark-prismjs/src/load-prism-language-extension.js","lineNumber":16,"sourceCode":"const Prism = require(`prismjs`)\nconst loadPrismLanguage = require(`./load-prism-language`)\nconst replaceStringWithRegex = require(`./replace-string-with-regexp`)\n\nmodule.exports = languageExtensions => {\n  // Create array of languageExtensions (if input is object)\n  languageExtensions = [].concat(languageExtensions)\n\n  languageExtensions.forEach(l => {\n    loadLanguageExtension(l)\n  })\n}\n\nconst loadLanguageExtension = languageExtension => {\n  if (!isObjectAndNotArray(languageExtension)) {\n    throw new Error(\n      `A languageExtension needs to be defined as an object. Given config is not valid: ${JSON.stringify(\n        languageExtension\n      )}`\n    )\n  }\n\n  if (!containsMandatoryProperties(languageExtension)) {\n    throw new Error(\n      `A languageExtension needs to contain 'language' and 'extend' or both and a 'definition'. Given config is not valid: ${JSON.stringify(\n        languageExtension\n      )}`\n    )\n  }\n\n  // If only 'extend' property is given, we extend the given extend language.\n  if (!languageExtension.language) {\n    languageExtension.language = languageExtension.extend\n  }","sourceCodeStart":1,"sourceCodeEnd":34,"githubUrl":"https://github.com/gatsbyjs/gatsby/blob/8b06340921ffdf23125a365b9c9923690cb62ce6/packages/gatsby-remark-prismjs/src/load-prism-language-extension.js#L1-L34","documentation":"Thrown by load-prism-language-extension in gatsby-remark-prismjs when a language extension entry is not a plain object (is an array, string, number, null, etc.). The function expects each extension to be an object with language/extend/definition keys.","triggerScenarios":"isObjectAndNotArray(languageExtension) returns false because the entry is a primitive, array, or null; happens when languageExtensions config contains a non-object entry.","commonSituations":"User configures languageExtensions as an array of strings instead of objects, passes a single string instead of an object, or includes a null/undefined entry.","solutions":["Ensure each entry in the languageExtensions config is an object with at least 'extend' or 'language' and a 'definition' property.","Wrap single string entries into objects: { language: 'mylang', extend: 'c', definition: '...' }.","Remove null or undefined entries from the config array.","Check the JSON structure of the config file for syntax errors that produce non-object values."],"exampleFix":"// before\noptions: { languageExtensions: ['mylang'] }\n// after\noptions: {\n  languageExtensions: [{\n    language: 'mylang',\n    extend: 'clike',\n    definition: Prism.languages.mylang\n  }]\n}","handlingStrategy":"validation","validationCode":"// Validate languageExtensions config before passing to plugin\nconst validExtensions = [].concat(languageExtensions).filter(\n  ext => typeof ext === 'object' && ext !== null && !Array.isArray(ext)\n)\nif (validExtensions.length !== [].concat(languageExtensions).length) {\n  throw new Error('All languageExtensions must be objects')\n}","typeGuard":"const isPlainObject = (val: unknown): val is Record<string, unknown> =>\n  typeof val === 'object' && val !== null && !Array.isArray(val)","tryCatchPattern":null,"preventionTips":["Ensure every languageExtensions entry is a plain object, not a string or array.","Validate config shape in a pre-build script.","Use a JSON schema validator for plugin options."],"tags":["gatsby","prismjs","remark","configuration","validation"],"backgroundTag":null,"analyzedSha":"8b06340921ffdf23125a365b9c9923690cb62ce6","analyzedAt":"2026-08-13T02:36:21.405Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}