{"record":{"id":"667ab7035cad5562","repo":"mjmlio/mjml","slug":"dependencies-must-be-an-object","errorCode":null,"errorMessage":"\"dependencies\" must be an object.","messagePattern":"\"dependencies\" must be an object\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"packages/mjml-validator/src/dependencies.js","lineNumber":23,"sourceCode":"\n  for (const source of sources) {\n    if (typeof source === 'object' && source !== null) {\n      for (const tag of Object.keys(source)) {\n        if (typeof tag === 'string') {\n          const list = []\n          if (target[tag]) {\n            list.push(...target[tag])\n          }\n          if (source[tag]) {\n            list.push(...source[tag])\n          }\n          target[tag] = Array.from(new Set(list))\n        } else {\n          console.warn('dependency \"tag\" must be of type string')\n        }\n      }\n    } else {\n      console.warn('\"dependencies\" must be an object.')\n    }\n  }\n  return target\n}\n\nconst dependencies = {}\n\nexport const registerDependencies = (dep) => {\n  assignDependencies(dependencies, dep)\n}\n\nexport default dependencies\n","sourceCodeStart":5,"sourceCodeEnd":36,"githubUrl":"https://github.com/mjmlio/mjml/blob/6c01d35af5da14108b86bbf052232e99de7ca755/packages/mjml-validator/src/dependencies.js#L5-L36","documentation":"assignDependencies expects its first argument to be a plain object mapping tags to arrays. When the dependencies argument is not an object (null, array misuse, string, undefined), it warns '\"dependencies\" must be an object.' and returns an empty/unchanged target, so no dependencies get registered.","triggerScenarios":"Calling registerDependencies(null), registerDependencies('mj-button'), or passing a non-object from a misparsed config into registerDependencies/assignDependencies.","commonSituations":"Config file failed to parse and yielded null; a caller passed a list instead of a map; optional import resolved to undefined; refactors renaming the config field.","solutions":["Pass a well-formed object: registerDependencies({ 'mj-accordion': ['mj-accordion-element'] })","Validate the argument before calling: if (deps && typeof deps === 'object' && !Array.isArray(deps))","Fix the upstream config loading that produced null/undefined","Add a fallback default ({} ) at the call site"],"exampleFix":"// before\nregisterDependencies(config.dependencies) // undefined\n// after\nconst deps = config.dependencies && typeof config.dependencies === 'object' ? config.dependencies : {}\nregisterDependencies(deps)","handlingStrategy":"type-guard","validationCode":"if (deps == null || typeof deps !== 'object' || Array.isArray(deps)) {\n  throw new Error('dependencies must be an object of tag -> array')\n}","typeGuard":"const isDependenciesObject = (d) => d != null && typeof d === 'object' && !Array.isArray(d)","tryCatchPattern":null,"preventionTips":["Default to {} when dependencies config is absent","Check config parsing results before passing them to registerDependencies","Avoid passing arrays or strings where a tag->array map is expected","Add schema validation for the dependencies config section"],"tags":["validation","type-error","mjml","dependencies","registerdependencies"],"backgroundTag":"invalid-dependency-config","analyzedSha":"6c01d35af5da14108b86bbf052232e99de7ca755","analyzedAt":"2026-09-02T21:31:03.649Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-10T02:17:09.455Z"}