Skip to content

fix: explain that every task requires a valid config in HHE15 - #8888

Open
yash251 wants to merge 1 commit into
NomicFoundation:mainfrom
yash251:yash/7122-hhe15-config-message
Open

yash251 wants to merge 1 commit into
NomicFoundation:mainfrom
yash251:yash/7122-hhe15-config-message

Conversation

@yash251

@yash251 yash251 commented Nov 28, 2026

Copy link
Copy Markdown
  • I have read CONTRIBUTING.md and this PR follows its rules.
  • Because this PR includes a bug fix, it fixes a scenario real users can hit, and relevant tests have been included.

Fixes #7122

This PR applies the change the Hardhat team asked for in the issue. In this comment, the team decided to keep the current config loading logic and make HHE15 explain that a valid config is needed for every task. The comment also gives the exact new message. This PR uses that text as written. The only edit is dropping a trailing space after the first line.

Users hit this when the config is invalid and they run a task that looks unrelated to it, like npx hardhat keystore set. Before, they only saw Invalid config:, with nothing saying why keystore needs the config at all.

Before:

Error HHE15: Invalid config:
	* Config error in config.networks.op.accounts.0: Expected a hex-encoded private key or a Configuration Variable

After:

Error HHE15: Hardhat requires a valid hardhat.config.ts file to identify and execute all tasks.
Hardhat couldn't run because the configuration is invalid:
	* Config error in config.networks.op.accounts.0: Expected a hex-encoded private key or a Configuration Variable

Changes

  • packages/hardhat-errors/src/descriptors.ts: new messageTemplate for CORE.GENERAL.INVALID_CONFIG (HHE15). The error number, title and arguments are unchanged.
  • packages/hardhat-errors/test/errors.ts: a test that checks the full HHE15 message.
  • A patch changeset for @nomicfoundation/hardhat-errors.

The other tests that check INVALID_CONFIG build the expected message from the descriptor, so they did not need changes.

Testing

  • pnpm test:file packages/hardhat-errors/test/errors.ts: the new test failed before the change (it got HHE15: Invalid config:). After the change, 39 passing.
  • pnpm lint in packages/hardhat-errors: passes.
  • pnpm test:file on the other tests that use INVALID_CONFIG, all passing:
    • packages/hardhat/test/internal/core/config-validation.ts, packages/hardhat/test/internal/core/tasks/task-manager.ts, packages/hardhat/test/internal/builtin-plugins/solidity-test/config-validation.ts (185 passing)
    • packages/hardhat-ledger/test/config-validation.ts (7 passing)
    • packages/hardhat-typechain/test/config-validation.ts (3 passing)
    • packages/hardhat-node-test-runner/test/index.ts (7 passing)
    • packages/hardhat-mocha/test/index.ts (9 passing)

Use the message text proposed by the Hardhat team in NomicFoundation#7122.
@changeset-bot

changeset-bot Bot commented Nov 28, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 2be926e

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@nomicfoundation/hardhat-errors Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

hardhat command evaluates hardhat.config.ts for system commands like keystore

2 participants