{"record":{"id":"898020538bf0510e","repo":"angular/angular-cli","slug":"msg-nan-error-occurred-inlining-file-options","errorCode":null,"errorMessage":"${msg}\\nAn error occurred inlining file \"${options.filename}\"","messagePattern":"(.+?)\\\\nAn error occurred inlining file \"(.+?)\"","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/angular_devkit/build_angular/src/utils/process-bundle.ts","lineNumber":140,"sourceCode":"  await loadLocalizeTools();\n\n  let ast: ParseResult | undefined | null;\n  try {\n    ast = parseSync(options.code, {\n      babelrc: false,\n      configFile: false,\n      sourceType: 'unambiguous',\n      filename: options.filename,\n    });\n  } catch (error) {\n    assertIsError(error);\n\n    // Make the error more readable.\n    // Same errors will contain the full content of the file as the error message\n    // Which makes it hard to find the actual error message.\n    const index = error.message.indexOf(')\\n');\n    const msg = index !== -1 ? error.message.slice(0, index + 1) : error.message;\n    throw new Error(`${msg}\\nAn error occurred inlining file \"${options.filename}\"`, {\n      cause: error,\n    });\n  }\n\n  if (!ast) {\n    throw new Error(`Unknown error occurred inlining file \"${options.filename}\"`);\n  }\n\n  if (!USE_LOCALIZE_PLUGINS) {\n    return inlineLocalesDirect(ast, options);\n  }\n\n  const diagnostics = [];\n  for (const locale of i18n.inlineLocales) {\n    const isSourceLocale = locale === i18n.sourceLocale;\n    // eslint-disable-next-line @typescript-eslint/no-explicit-any\n    const translations: any = isSourceLocale ? {} : i18n.locales[locale].translation || {};\n    let localeDataContent;","sourceCodeStart":122,"sourceCodeEnd":158,"githubUrl":"https://github.com/angular/angular-cli/blob/bb72145f9ab45aee29f523236b3a25cd0813a841/packages/angular_devkit/build_angular/src/utils/process-bundle.ts#L122-L158","documentation":"When the inlining transformation of a bundle throws, inlineLocales wraps the failure with this message to make it readable: the underlying error message often contains the entire file content, so only the text up to the first ')\\n' is kept, and the failing filename is appended. The original error is attached as `cause`.","triggerScenarios":"Any exception thrown during translation/inlining of a specific bundle file inside inlineLocales — e.g. the localize plugins or translation parser fail while processing options.filename.","commonSituations":"Malformed translation files (broken XLF/ARB JSON), translation files referencing missing translation units, or a corrupt/generated bundle that cannot be re-parsed during i18n inlining.","solutions":["Inspect `error.cause` for the original, full error message to find the real failure.","Validate and fix the translation file(s) for the locale being inlined (well-formed XLF/ARB, matching source strings).","Rebuild the bundle from source; if the input bundle itself is corrupt, clean and rebuild before inlining."],"exampleFix":"// before: unreadable wrapped error\nthrow new Error(`${msg}\\nAn error occurred inlining file \"${options.filename}\"`, { cause: error });\n// after: surface cause when debugging\ntry { await inlineLocales(options); } catch (e) { console.error(e.cause ?? e); throw e; }","handlingStrategy":"try-catch","validationCode":"const translationFiles = i18nOptions.locales.map((l) => l.translation);\nfor (const f of translationFiles) {\n  if (!fs.existsSync(f)) throw new Error(`Missing translation file: ${f}`);\n}","typeGuard":"function hasReadableCause(e: unknown): e is Error & { cause: unknown } {\n  return e instanceof Error && 'cause' in e;\n}","tryCatchPattern":"try {\n  await inlineLocales(options);\n} catch (e) {\n  if (hasReadableCause(e)) {\n    console.error(`Inlining failed for ${options.filename}:`, e.cause);\n  }\n  throw e;\n}","preventionTips":["Validate all translation files (XLF/ARB) parse before building.","Keep @angular/localize and build-angular versions in sync.","Log `error.cause` when this wrapped error appears to see the root message.","Clean rebuild when the input bundle may be stale or corrupt."],"tags":["i18n","angular-cli","error-wrapping","build"],"backgroundTag":"inlining-failed","analyzedSha":"bb72145f9ab45aee29f523236b3a25cd0813a841","analyzedAt":"2026-08-30T02:47:34.745Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}