{"record":{"id":"f709fc026a3c45fa","repo":"nodejs/node","slug":"providerentity-must-be-specified-with-entityk-f709fc","errorCode":null,"errorMessage":"${providerEntity} must be specified with ${entityKey} option","messagePattern":"(.+?) must be specified with (.+?) option","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"deps/npm/lib/trust-cmd.js","lineNumber":302,"sourceCode":"\n    if (invalidPkgJsonProviderType) {\n      const message = this.warnString`Repository in package.json is not a ${providerEntity}`\n      if (!flags[entityKey]) {\n        throw new Error(message)\n      } else {\n        warnings.push(message)\n      }\n    } else {\n      if (mismatchPkgJsonRepository) {\n        warnings.push(this.warnString`Repository in package.json (${git.repository}) differs from provided ${providerEntity} (${entity})`)\n      }\n    }\n\n    if (!entity && matchPkg) {\n      throw new Error(`${providerEntity} must be specified with ${entityKey} option or inferred from the package.json repository field`)\n    }\n    if (!entity) {\n      throw new Error(`${providerEntity} must be specified with ${entityKey} option`)\n    }\n\n    this.validateEntity(entity)\n\n    return {\n      values: {\n        package: pkgName,\n        file: flags.file,\n        [entityKey]: entity,\n        ...(flags.environment && { environment: flags.environment }),\n      },\n      fromPackageJson: {\n        [entityKey]: usedRepositoryInPkgJson,\n        package: usedPkgNameFromPkgJson,\n      },\n      warnings: warnings,\n      urls: {\n        package: this.getFrontendUrl({ pkgName }),","sourceCodeStart":284,"sourceCodeEnd":320,"githubUrl":"https://github.com/nodejs/node/blob/1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e/deps/npm/lib/trust-cmd.js#L284-L320","documentation":"Thrown by TrustCommand.flagsToOptions when no entity was resolved AND matchPkg is false (the positional package name given does NOT match the package.json name), i.e. the user is configuring trust for a different package than the one in the cwd, so package.json repository inference is intentionally skipped, and without an explicit entity flag there is nothing to use. The message drops the 'inferred from package.json' clause because that path is not applicable here.","triggerScenarios":"Running `npm trust gitlab other-pkg --file .gitlab-ci.yml --allow-publish` (positional differs from local package.json name) without `--project`. Since positional != pkgJsonName, matchPkg is false; entity stays undefined; this branch fires.","commonSituations":"Configuring trust for a package you don't have checked out locally; cross-package scripting where cwd differs from the target package.","solutions":["Provide the entity flag: `--project group/proj` (gitlab) / `--repo owner/repo` (github).","If you intended to use the local package's repository, drop the mismatched positional so matchPkg becomes true.","Run the command from within the target package's own checkout so its package.json applies."],"exampleFix":"// before\nnpm trust gitlab other-pkg --file .gitlab-ci.yml --allow-publish\n// after\nnpm trust gitlab other-pkg --file .gitlab-ci.yml --project group/proj --allow-publish","handlingStrategy":"validation","validationCode":"if (!entity && !matchPkg) {\n  throw new Error(`Targeting a different package (${positional}); pass --${entityKey} explicitly since package.json inference is skipped`)\n}","typeGuard":"const hasEntityForForeignPkg = (entity, flags, entityKey) =>\n  Boolean(entity) || Boolean(flags && flags[entityKey])","tryCatchPattern":"try {\n  await createConfigCommand(...)\n} catch (err) {\n  if (/must be specified with .* option$/i.test(err.message)) {\n    // pass the explicit entity flag matching the foreign package's repo, then retry\n  } else { throw err }\n}","preventionTips":["When configuring trust for a package other than the cwd's, always pass the entity flag.","Run trust commands from within the target package's checkout when possible.","Document which entity each script targets to avoid mismatched positionals."],"tags":["validation","trust","cli-args","repository"],"backgroundTag":null,"analyzedSha":"1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e","analyzedAt":"2026-08-13T00:53:24.642Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}