{"record":{"id":"4d09687726e0728b","repo":"angular/angular-cli","slug":"did-not-find-valid-angular-bestpractices-metadat","errorCode":null,"errorMessage":"Did not find valid 'angular.bestPractices' metadata in '${pkgJsonPath}'. Falling back to the bundled guide.","messagePattern":"Did not find valid 'angular\\.bestPractices' metadata in '(.+?)'\\. Falling back to the bundled guide\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"packages/angular/cli/src/commands/mcp/tools/best-practices.ts","lineNumber":179,"sourceCode":"\n      // Check the file size to prevent reading a very large file.\n      const stats = await stat(guidePath);\n      if (stats.size > 1024 * 1024) {\n        // 1MB\n        logger.warn(\n          `The best practices guide at '${guidePath}' is larger than 1MB (${stats.size} bytes). ` +\n            'This is unexpected and the file will not be read. Falling back to the bundled guide.',\n        );\n\n        return undefined;\n      }\n\n      const content = await readFile(guidePath, 'utf-8');\n      const source = `framework version ${pkgJson.version}`;\n\n      return { content, source };\n    } else {\n      logger.warn(\n        `Did not find valid 'angular.bestPractices' metadata in '${pkgJsonPath}'. ` +\n          'Falling back to the bundled guide.',\n      );\n    }\n  } catch (e) {\n    logger.warn(\n      `Failed to read or parse version-specific best practices referenced in '${pkgJsonPath}': ${\n        e instanceof Error ? e.message : e\n      }. Falling back to the bundled guide.`,\n    );\n  }\n\n  return undefined;\n}\n\n/**\n * Creates the handler function for the `get_best_practices` tool.\n * The handler orchestrates the process of first attempting to get a version-specific guide","sourceCodeStart":161,"sourceCodeEnd":197,"githubUrl":"https://github.com/angular/angular-cli/blob/bb72145f9ab45aee29f523236b3a25cd0813a841/packages/angular/cli/src/commands/mcp/tools/best-practices.ts#L161-L197","documentation":"When the CLI reads the installed @angular/core package.json looking for valid 'angular.bestPractices' metadata (a path to a version-specific guide), the metadata is missing or malformed. The CLI logs this warning and falls back to its bundled best-practices guide instead of failing.","triggerScenarios":"getVersionSpecificBestPractices resolves the package.json of the installed Angular framework, finds no valid 'angular.bestPractices' entry (missing, wrong type, or structurally invalid), and takes the else branch that logs this warning.","commonSituations":"Running against an older Angular version that predates the bestPractices metadata field; packages published by registries/mirrors that strip custom fields; third-party or patched @angular/core builds.","solutions":["Upgrade @angular/core to a version that ships valid 'angular.bestPractices' metadata.","Verify node_modules/@angular/core/package.json contains an 'angular' object with a valid 'bestPractices' field; reinstall if stripped.","Confirm your registry/mirror (e.g., Verdaccio, Nexus) doesn't strip custom package.json fields.","Accept the fallback: the bundled guide still provides best practices for the tool."],"exampleFix":"// before: node_modules/@angular/core/package.json without metadata\n{ \"name\": \"@angular/core\", \"version\": \"17.0.0\" }\n// after: upgrade so the metadata exists\n{ \"name\": \"@angular/core\", \"version\": \"20.0.0\", \"angular\": { \"bestPractices\": { \"path\": \"./guides/best-practices.md\" } } }","handlingStrategy":"validation","validationCode":"const pkg = JSON.parse(await readFile('node_modules/@angular/core/package.json', 'utf-8'));\nconst bp = pkg.angular?.bestPractices;\nif (!bp) console.warn('No angular.bestPractices metadata; CLI will use bundled guide');","typeGuard":"function hasBestPracticesMeta(pkg: any): boolean {\n  return typeof pkg?.angular?.bestPractices === 'object' && pkg.angular.bestPractices !== null;\n}","tryCatchPattern":"try {\n  guide = await getVersionSpecificBestPractices(...);\n} catch {\n  guide = bundledGuide; // metadata missing -> bundled fallback\n}","preventionTips":["Keep @angular/core on a version that ships bestPractices metadata.","Avoid registry mirrors that strip custom package.json fields.","Don't hand-edit package.json files inside node_modules.","Use `npm ci` so installed packages match published content."],"tags":["mcp","metadata","fallback","angular-cli"],"backgroundTag":"missing-package-metadata","analyzedSha":"bb72145f9ab45aee29f523236b3a25cd0813a841","analyzedAt":"2026-08-30T02:47:34.745Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}