{"record":{"id":"517412050b213574","repo":"vercel/next.js","slug":"specified-images-should-be-an-object-received-ty","errorCode":null,"errorMessage":"Specified images should be an object received ${typeof images}.\nSee more info here: https://nextjs.org/docs/messages/invalid-images-config","messagePattern":"Specified images should be an object received (.+?)\\.\nSee more info here: https://nextjs\\.org/docs/messages/invalid-images-config","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/next/src/server/config.ts","lineNumber":648,"sourceCode":"\n    if (result.basePath !== '/') {\n      if (result.basePath.endsWith('/')) {\n        throw new Error(\n          `Specified basePath should not end with /, found \"${result.basePath}\"`\n        )\n      }\n\n      if (result.assetPrefix === '') {\n        result.assetPrefix = result.basePath\n      }\n    }\n  }\n\n  if (result?.images) {\n    const images: ImageConfig = result.images\n\n    if (typeof images !== 'object') {\n      throw new Error(\n        `Specified images should be an object received ${typeof images}.\\nSee more info here: https://nextjs.org/docs/messages/invalid-images-config`\n      )\n    }\n\n    if (images.localPatterns) {\n      if (!Array.isArray(images.localPatterns)) {\n        throw new Error(\n          `Specified images.localPatterns should be an Array received ${typeof images.localPatterns}.\\nSee more info here: https://nextjs.org/docs/messages/invalid-images-config`\n        )\n      }\n      // avoid double-pushing the same pattern if it already exists\n      if (\n        !images.localPatterns.some(\n          (pattern) =>\n            pattern.pathname === '/_next/static/media/**' &&\n            pattern.search === ''\n        )\n      ) {","sourceCodeStart":630,"sourceCodeEnd":666,"githubUrl":"https://github.com/vercel/next.js/blob/0ae8c72462952df163f1b1e0726641bc5b40dc93/packages/next/src/server/config.ts#L630-L666","documentation":"When `images` is provided in the config, it must be an object literal matching the ImageConfig shape. The guard at config.ts:647-651 runs after the config is cast to ImageConfig, so any non-object truthy value (string, number, array, boolean) is rejected before any image-optimization defaults are applied. This prevents the downstream _next/image optimizer from dereferencing undefined properties like `images.domains`.","triggerScenarios":"Setting `images: 'cloudinary'`, `images: ['cloudinary']`, `images: true`, or any non-object truthy value in next.config. Also happens when a typo or bad merge leaves images as a primitive.","commonSituations":"Confusing the loader name string (`images: 'cloudinary'`) with the proper config object. Misreading older docs that put `loader` at a different level. Accidentally assigning the result of a function call that returns a string instead of an object.","solutions":["Set `images` to an object, e.g. `images: { loader: 'cloudinary', path: 'https://...' }`.","Remove the `images` key entirely if you want the defaults.","Verify with TypeScript by typing next.config: `const nextConfig: import('next').NextConfig = { images: { ... } }`."],"exampleFix":"// before\nmodule.exports = { images: 'cloudinary' }\n// after\nmodule.exports = { images: { loader: 'cloudinary', path: 'https://my-account.cloudinary.com' } }","handlingStrategy":"type-guard","validationCode":"if (config.images != null && (typeof config.images !== 'object' || Array.isArray(config.images))) {\n  throw new Error('images must be a plain object');\n}","typeGuard":"function isImageConfig(v: unknown): v is Record<string, unknown> {\n  return typeof v === 'object' && v !== null && !Array.isArray(v);\n}","tryCatchPattern":null,"preventionTips":["Type next.config as `NextConfig` so TypeScript rejects primitives for `images`.","Review config diffs that touch the `images` key."],"tags":["config","images","next-config","type-validation"],"analyzedSha":"0ae8c72462952df163f1b1e0726641bc5b40dc93","analyzedAt":"2026-08-06T19:44:29.143Z","schemaVersion":2},"datasetVersion":"2026-08-07T02:17:10.218Z"}