Cannot read properties of undefined (reading 'content')

Hi all,

When attempting to upgrade my contract, the upgrade core throws an error message such as the following:

:1234: Code to reproduce

forge clean && forge build
npx @openzeppelin/upgrades-core validate

:computer: Environment

  • Foundry version 0.2

Thanks in advance

Hi, are you using and can you check that you followed the steps in the Before Running section of the readme? It looks like it cannot find the source code for your contract from the build artifacts.

If that doesn't work, would you be able to share an example GitHub repo that encounters this issue?

Hi @ericglau

Sorry for being late.

For your information, I did follow the steps on the Readme. Could u tell me how can I find the source code from the build artifacts?

In your project's out/build-info folder, there should be a .json file. Source code should be in the JSON structure at input.sources[<fully qualified contract path>].content, for example:

  "_format": "ethers-rs-sol-build-info-1",
  "solcVersion": "0.8.20",
  "solcLongVersion": "0.8.20+commit.a1b79de6.Darwin.appleclang",
  "input": {
    "language": "Solidity",
    "sources": {
      "src/MyContract.sol": {
        "content": "<my contract's source code>"

Yes, I see all the sources and the smart contract that I cannot upgrade too. What should I do next?

Would you be able to share your repository, or a minimal example repository that has this issue?