Skip to content

[Bug] getAccount proceeds with file read after createKeypairByName failure causing unhandled ENOENT crash #304

Description

@zakaziko86

Bug Description

getAccount in src/lib/actions/BaseAction.ts (lines 130-136)
unconditionally reads the keystore file after calling
createKeypairByName, even if it failed and never created the file.

Root Cause

if(!existsSync(keystorePath)){awaitthis.confirmPrompt(`Account '${accountName}' not found. Would you like to create it?`);decryptedPrivateKey=awaitthis.createKeypairByName(accountName,false);}keystoreJson=readFileSync(keystorePath,"utf-8");// line 135: no error checkkeystoreData=JSON.parse(keystoreJson);// line 136

Impact

If createKeypairByName fails for any reason other than
password mismatch (e.g., disk full, permissions error during
writeFileSync), the keystore file is never created. The code
then crashes with an unhandled ENOENT error on line 135
instead of a clear error message.

Suggested Fix

decryptedPrivateKey=awaitthis.createKeypairByName(accountName,false);if(!existsSync(keystorePath)){this.failSpinner(`Failed to create keystore file for account '${accountName}'`);return;}

File

src/lib/actions/BaseAction.ts lines 130-136
Severity: High

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions