Skip to content

fix(devnet): only show init hint for InitializationError#408

Merged
RetricSu merged 6 commits intodevelopfrom
fix/devnet-config-hint
Mar 13, 2026
Merged

fix(devnet): only show init hint for InitializationError#408
RetricSu merged 6 commits intodevelopfrom
fix/devnet-config-hint

Conversation

@RetricSu
Copy link
Collaborator

Fixes #406

Problem

`offckb devnet config` was showing the "run `offckb node` once to initialize devnet config files first" hint for ALL errors, including user input errors like invalid `--set` syntax or validation failures. This was misleading.

Solution

  • Added `InitializationError` class to distinguish initialization errors from user input errors
  • Only show the init hint when catching `InitializationError` (missing config path, ckb.toml, or miner.toml)
  • Added type safety guard for error handling

Changes

  1. `src/devnet/config-editor.ts`: Added `InitializationError` class
  2. `src/devnet/config-editor.ts`: Updated throws to use `InitializationError` for missing files/paths
  3. `src/cmd/devnet-config.ts`: Updated catch block to conditionally show hint
  4. `tests/devnet-config-command.test.ts`: Added 6 unit tests for error classification

Testing

  • All 8 tests pass (2 existing + 6 new)
  • Verified: parse errors, validation errors → NO hint
  • Verified: missing config files → WITH hint

@github-actions
Copy link

github-actions bot commented Mar 13, 2026

✅ Changeset file detected.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR refines offckb devnet config error handling so the “run offckb node once…” initialization hint is only shown for true devnet initialization failures, instead of for all errors (including user input/validation issues).

Changes:

  • Introduces InitializationError in the devnet config editor and throws it for missing config path / missing required TOML files.
  • Updates devnetConfig to conditionally print the initialization hint only when catching InitializationError, while improving catch type-safety.
  • Adds unit tests to verify hint behavior across parse errors, validation/unknown-field errors, and initialization errors.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
src/devnet/config-editor.ts Adds InitializationError and uses it for missing path/config-file checks.
src/cmd/devnet-config.ts Prints the initialization hint only for InitializationError; safer error-to-message handling.
tests/devnet-config-command.test.ts Adds tests ensuring the hint is suppressed for non-init errors and shown for init errors.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.


describe('error handling with init hint', () => {
beforeEach(() => {
jest.clearAllMocks();
@RetricSu RetricSu merged commit 37189f7 into develop Mar 13, 2026
6 checks passed
@RetricSu RetricSu deleted the fix/devnet-config-hint branch March 13, 2026 07:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

offckb devnet config shows “run offckb node once” hint for non-initialization errors

2 participants