Skip to content

fix(forge): improve error messages for etherscan verification failures #11194

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

shiyasmohd
Copy link
Contributor

@shiyasmohd shiyasmohd commented Aug 4, 2025

Motivation

Unclear err message for the below situations.

  • When attempting to verify on an unsupported chain.
  • When verification fails due to compiler version mismatches, users receive a generic "No matching artifact found" error without understanding the root cause.

Solution

  • Better error message
  • Handle error cases in ResolvedEtherscanConfig::create()

Closes #11186

Copy link
Collaborator

@grandizzy grandizzy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you, looks good so far, could you please add also test to make sure we early catch any regression ?
@zerosnacks pls chime in re messages to display. Thank you!

@shiyasmohd
Copy link
Contributor Author

@grandizzy Added tests now.

@shiyasmohd shiyasmohd force-pushed the shiyasmohd/better-err-msg-for-verify-cmd branch from ebb9b72 to 8cb4749 Compare August 4, 2025 18:48
@zerosnacks
Copy link
Member

Thanks @shiyasmohd!

Error messages makes sense, code lgtm 👍

@DaniPopes DaniPopes requested a review from grandizzy August 4, 2025 21:22
@shiyasmohd
Copy link
Contributor Author

Thanks for the suggestions @DaniPopes. Pushed the changes.

Copy link
Collaborator

@grandizzy grandizzy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you, lgtm!

@grandizzy grandizzy merged commit 0e7eca2 into foundry-rs:master Aug 5, 2025
22 checks passed
@github-project-automation github-project-automation bot moved this to Done in Foundry Aug 5, 2025
grandizzy pushed a commit to grandizzy/foundry that referenced this pull request Aug 5, 2025
foundry-rs#11194)

* fix(forge): improve error messages for etherscan verification failures

* fix: cargo clippy

* tests(forge): add tests for unknown chain id

* fix: err formating for EtherscanConfigError

---------

Co-authored-by: zerosnacks <[email protected]>
@grandizzy grandizzy mentioned this pull request Aug 5, 2025
3 tasks
grandizzy added a commit that referenced this pull request Aug 5, 2025
* fix(cast): use all providers if local artifacts used (#11090)

* fix(cast): use all providers if local artifacts used

* Fix

* fix(cast): improve handling of `mktx --raw-unsigned` with runtime validation (#11111)

* fix(mktx): improve handling of `--raw-unsigned` with runtime validation

- Updated the logic for handling the `--from` argument in the `run` function.
- Added validation for required `nonce` parameter when `--from` is not provided, ensuring necessary transaction details are specified.
- Used `Address::ZERO` as a placeholder when there is no need to query provider
- unit tests

* fix: fmt

* fix(`anvil`): unwrap panic in `eth/backend/mem/mod.rs` (#11141)

make typed request casting not panic and return useful error to user

* fix(forge): consistent handling unresolved imports (#11164)

* fix(forge): consistent handling unresolved imports

* Add test

* fix(lint): exclude disabled ids in multi-lint passes (#11122)

* fix: use empty 7702 auths (#11182)

* fix(forge): bump compilers to fix remapping sol file (#11184)

* Bump compilers 0.18.2

* Add test

* fix(coverage): disambiguate duplicate function names (#11188)

* fix(forge): set state changes journal in active fork (#11196)

* chore(ci): fix `typos` CI job failing (#11198)

fix typos

* Bump version 1.3.1 (#11199)

* fix(forge): improve error messages for etherscan verification failures (#11194)

* fix(forge): improve error messages for etherscan verification failures

* fix: cargo clippy

* tests(forge): add tests for unknown chain id

* fix: err formating for EtherscanConfigError

---------

Co-authored-by: zerosnacks <[email protected]>

* chore(tests): bump forge-std version (#11174)

* chore: bump forge-std version used for tests

* Fixes

---------

Co-authored-by: DaniPopes <[email protected]>
Co-authored-by: grandizzy <[email protected]>

---------

Co-authored-by: Mablr <[email protected]>
Co-authored-by: zerosnacks <[email protected]>
Co-authored-by: 0xrusowsky <[email protected]>
Co-authored-by: Matthias Seitz <[email protected]>
Co-authored-by: DaniPopes <[email protected]>
Co-authored-by: Shiyas Mohammed <[email protected]>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: DaniPopes <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

forge verify-contract fails with perplexing error message for unrecognized chains
4 participants