Skip to content

policy tests fail if there is a package.json in parent directories #35600

Description

@jasnell

Just opening this so it's not forgotten.... Policy tests can fail if there is a package.json in the parent path of the local node.js repo

Error [ERR_MANIFEST_ASSERT_INTEGRITY]: The content of "file:///home/james/package.json" does not match the expected integrity. The resource was not found in the policy.
    at new NodeError (node:internal/errors:258:15)
    at Manifest.assertIntegrity (node:internal/policy/manifest:532:19)
    at Object.read (node:internal/modules/package_json_reader:34:16)
    at readPackage (node:internal/modules/cjs/loader:259:36)
    at readPackageScope (node:internal/modules/cjs/loader:292:19)
    at shouldUseESMLoader (node:internal/modules/run_main:36:15)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:67:24)
    at node:internal/main/run_main_module:17:47 {
  code: 'ERR_MANIFEST_ASSERT_INTEGRITY'
}

    at Object.<anonymous> (/home/james/node/node/test/parallel/test-policy-integrity-flag.js:64:10)
    at Module._compile (node:internal/modules/cjs/loader:1072:30)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1101:10)
    at Module.load (node:internal/modules/cjs/loader:937:32)
    at Function.Module._load (node:internal/modules/cjs/loader:778:14)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:72:12)
    at node:internal/main/run_main_module:17:47 {
  generatedMessage: false,
  code: 'ERR_ASSERTION',
  actual: 1,
  expected: 0,
  operator: 'strictEqual'
}
Command: out/Release/node /home/james/node/node/test/parallel/test-policy-integrity-flag.js

What steps will reproduce the bug?

How often does it reproduce? Is there a required condition?

What is the expected behavior?

What do you see instead?

Additional information

Activity

  1. bmeck commented on Oct 12, 2020

    @bmeck
    Member

    @jasnell this is intentional since that is how policies work, the CJS/ESM loaders crawl up to find "type" from package.json files and if it finds one that isn't allowed it fails. Is there some issue that needs to be fixed?

  2. jasnell commented on Oct 12, 2020

    @jasnell
    MemberAuthor

    Yes, I get that, it's just unexpected for the test suite to fail due to some factor completely outside of the project repo. Ideally there would be a way of sandboxing it or limiting the search path... or, if that's not possible, to provide a better error that describes why it's failing.

  3. bmeck commented on Oct 12, 2020

    @bmeck
    Member

    we could also just put a well known package.json in the test directory

  4. targos commented on Oct 13, 2020

    @targos
    Member

    we could also just put a well known package.json in the test directory

    Good idea. I'm on it.

  5. targos commented on Oct 13, 2020

    @targos
    Member

    Actually, I don't understand what needs to be changed to make it work, feel free to pick it up 😄 .

  6. added
    policyHistorical issues and PRs related to the removed policy-manifest feature.
    testIssues and PRs related to Node.js core tests and test infrastructure.
    on Oct 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    policyHistorical issues and PRs related to the removed policy-manifest feature.testIssues and PRs related to Node.js core tests and test infrastructure.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions