mjmlio/mjml · warning
"dependencies" must be an object.
Error message
"dependencies" must be an object.
What it means
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.
Source
Thrown at packages/mjml-validator/src/dependencies.js:23
for (const source of sources) {
if (typeof source === 'object' && source !== null) {
for (const tag of Object.keys(source)) {
if (typeof tag === 'string') {
const list = []
if (target[tag]) {
list.push(...target[tag])
}
if (source[tag]) {
list.push(...source[tag])
}
target[tag] = Array.from(new Set(list))
} else {
console.warn('dependency "tag" must be of type string')
}
}
} else {
console.warn('"dependencies" must be an object.')
}
}
return target
}
const dependencies = {}
export const registerDependencies = (dep) => {
assignDependencies(dependencies, dep)
}
export default dependencies
View on GitHub (pinned to 6c01d35af5)
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
Example fix
// before
registerDependencies(config.dependencies) // undefined
// after
const deps = config.dependencies && typeof config.dependencies === 'object' ? config.dependencies : {}
registerDependencies(deps) Defensive patterns
Strategy: type-guard
Validate before calling
if (deps == null || typeof deps !== 'object' || Array.isArray(deps)) {
throw new Error('dependencies must be an object of tag -> array')
} Type guard
const isDependenciesObject = (d) => d != null && typeof d === 'object' && !Array.isArray(d)
Prevention
- 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
When it happens
Trigger: Calling registerDependencies(null), registerDependencies('mj-button'), or passing a non-object from a misparsed config into registerDependencies/assignDependencies.
Common situations: 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.
Related errors
- dependency "tag" must be of type string
- "dependencies" option should be provided to mjml validator
- An mj-head element add an unkown head attribute : ${attr} wi
- ValidationError: \n ${errors.map((e) => e.formattedMessage).
- Malformed MJML. Check that your structure is correct and enc
AI-assisted analysis of mjmlio/mjml@6c01d35af5 (2026-09-02).
Data as JSON: /api/errors/667ab7035cad5562.
Report an issue: GitHub.