Skip to content
This repository was archived by the owner on Jun 11, 2024. It is now read-only.

Offline transaction signing gives a misleading error message #9092

Closed
bobanm opened this issue Oct 16, 2023 · 0 comments
Closed

Offline transaction signing gives a misleading error message #9092

bobanm opened this issue Oct 16, 2023 · 0 comments
Assignees
Milestone

Comments

@bobanm
Copy link
Contributor

bobanm commented Oct 16, 2023

Actual behavior

When signing transaction using --offline flag, if there is any error, the real error message is replaced by an incorrect and misleading error:

Application at data path <data-path> is not running.

This makes no sense, because a running node is not needed for offline signing. Even worse, this misleading error makes it very difficult for a user to understand what the real error is.

Expected behavior

Command should return the correct error, which will help the user correct the command input.

Steps to reproduce

While a node is not running, sign transaction offline and provide an invalid value for a flag, e.g. key derivation path:

./bin/run transaction:sign 0a05746f6b656e12087472616e73666572180020c0843d2a20a3f96c50d0446220ef2f98240898515cbba8155730679ca35326d98dcfb680f032340a0804000000000000001080a0b787e9051a14768d592cef5fce076bbd551445cc66a5eeb13393220b676f7420746f6b656e733f3a406fefadbba4d6495a2f632ea2d3a3de405334c974ba77287fb25e25e7a20c46f38c64c0f54069e60a33ee54f3cda7bb10c403d650c78a322b651b0af83cbe2e03 --offline --chain-id 04000000 --key-derivation-path invalid

In this case, the expected error is that key derivation path is invalid.

Which version(s) does this affect? (Environment, OS, etc...)

The latest SDK 6.0 version.

How to fix it

The transaction:sign command contains custom logic which re-throws a custom error if application is not running:

if (error) {
    if (this._dataPath && !isApplicationRunning(this._dataPath)) {
        throw new Error(`Application at data path ${this._dataPath} is not running.`);
    }
    this.error(error instanceof Error ? error.message : error);
}

This does not correctly cover the case when signing is done in offline mode. Furthermore, this custom logic is not even needed. The check if the application is running is already correctly done when getting the API client, and that function throws the correct error:

this._client = await getApiClient(this._dataPath, this.config.pjson.name);

Additional request

Since the concept of a "path" could mean different things, it would be nice to make the invalid key derivation path error message more specific by changing it from Invalid path format into Invalid key derivation path format.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants