{"record":{"id":"fe7782936447135a","repo":"abhigyanpatwari/GitNexus","slug":"node-package-name-discovered-ambiguous-length-candidate","errorCode":null,"errorMessage":"[node] package ${name}: ${discovered.ambiguous.length} candidate source entries (${discovered.ambiguous.join(', ')}) — none adopted; declare `source` or a single lib entry","messagePattern":"\\[node\\] package (.+?): (.+?) candidate source entries \\((.+?)\\) — none adopted; declare `source` or a single lib entry","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"gitnexus/src/core/ingestion/import-resolvers/node-workspace-packages.ts","lineNumber":649,"sourceCode":"  // resolved calls against ~845 raw. Tried in a fixed order, and ONLY appended\n  // (declared entries keep precedence): `source` / `publishConfig.source`, the\n  // vite `lib.entry`, then `src/main` / `src/index`. More than one candidate\n  // that exists on disk is recorded as ambiguous rather than picked — a wrong\n  // entry binds every import of the package to the wrong file.\n  // A package whose `exports` map has no `\".\"` (only subpaths) refuses the bare\n  // specifier outright; discovery must not manufacture a `src/index` root for it.\n  const rootlessExports = declaresExports && rootExports.length === 0;\n  const discovered = rootlessExports\n    ? { entries: [], ambiguous: [], allowConventional: false }\n    : await discoverSourceEntries(parsed, dir, repoRoot);\n  for (const entry of discovered.entries) push(entries, entry);\n  if (!declaresExports && discovered.allowConventional) {\n    for (const conventional of ['src/index', 'index', 'lib/index']) {\n      push(entries, joinRepoPath(packageDir, conventional));\n    }\n  }\n  if (discovered.ambiguous.length > 0) {\n    logger.warn(\n      `[node] package ${name}: ${discovered.ambiguous.length} candidate source entries (${discovered.ambiguous.join(', ')}) — none adopted; declare \\`source\\` or a single lib entry`,\n    );\n  }\n\n  const subpathImports = new Map<string, readonly string[]>();\n  collectImports(parsed.imports, subpathImports, rebase);\n\n  return { name, package: { dir: packageDir, entries, subpathExports, subpathImports } };\n}\n\n/**\n * Walk an `exports` value into the root-entry list and the subpath map.\n *\n * `exports` nests three ways at once — a bare string, a subpath map, and\n * condition maps (`import` / `require` / `types` / `default`) at any depth — so\n * this collects string leaves per subpath rather than assuming a shape.\n */\nfunction collectExports(","sourceCodeStart":631,"sourceCodeEnd":667,"githubUrl":"https://github.com/abhigyanpatwari/GitNexus/blob/ac9a4e9abd8fd3058c070b72c23402a4f887929a/gitnexus/src/core/ingestion/import-resolvers/node-workspace-packages.ts#L631-L667","documentation":"This is a logged warning (not a thrown error) emitted while reading a workspace package's manifest. GitNexus tries to infer a package's source entry point for import resolution; when the package has multiple ambiguous candidate entries (e.g. both `src/index` and `lib/index` exist, or several discovery sources produced candidates) it refuses to guess, adopts none, and warns. Imports into that package may then resolve less precisely until the package declares an explicit entry.","triggerScenarios":"Analyzing a workspace package whose package.json declares neither `exports` nor an unambiguous `source`/single-lib entry, while more than one conventional candidate source file exists on disk (discovered.ambiguous non-empty). Raised from readManifest during `gitnexus analyze` of a Node workspace.","commonSituations":"Packages with both a compiled `lib/index.js` and a `src/index.ts`; packages publishing multiple top-level bundles; legacy packages migrated from a build layout but never declaring `exports` or `source` in package.json.","solutions":["Add an explicit `source` field to the package's package.json pointing at the canonical entry (e.g. \"source\": \"./src/index.ts\").","Declare `exports` in package.json so the resolver has an unambiguous entry map instead of falling back to conventional discovery.","Remove or rename the extra candidate entry (e.g. delete a stale duplicate `index.ts` at the package root or an obsolete `lib/index`) so only one candidate remains.","If the ambiguity is intentional (multi-entry package), accept the warning; resolution will fall back to other heuristics for that package."],"exampleFix":"// before: package.json with ambiguous entries on disk (src/index.ts AND lib/index.js)\n{ \"name\": \"my-pkg\", \"main\": \"./lib/index.js\" }\n// after: declare an explicit source entry\n{ \"name\": \"my-pkg\", \"main\": \"./lib/index.js\", \"source\": \"./src/index.ts\" }","handlingStrategy":"validation","validationCode":"// pre-flight check per workspace package\nconst pkg = JSON.parse(fs.readFileSync('package.json', 'utf8'));\nconst ambiguous = ['src/index.ts','index.ts','lib/index.js'].filter(f => fs.existsSync(f));\nif (!pkg.exports && !pkg.source && ambiguous.length > 1) {\n  console.warn(`declare \\`source\\` or exports; ambiguous entries: ${ambiguous.join(', ')}`);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always declare `exports` or `source` in workspace package manifests","Avoid shipping both src/index and lib/index in the same package","Add a lint check that each publishable package has exactly one entry convention"],"tags":["node","package-resolution","ambiguity","workspace"],"backgroundTag":"unexpected-response-shape","analyzedSha":"ac9a4e9abd8fd3058c070b72c23402a4f887929a","analyzedAt":"2026-09-15T23:29:44.066Z","contentChangedAt":"2026-09-15T23:29:44.066Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}