Skip to content

[Bug] config reset contains dead code - delete operation never persisted to disk #305

Description

@zakaziko86

Bug Description

reset in src/commands/config/getSetReset.ts (lines 38-50)
contains a completely useless delete config[key] statement
that modifies a local object which is never written back to disk.

Root Cause

reset(key: string): void {
    const config = this.getConfig();     // reads fresh config from disk
    if (!(key in config)) {
      this.failSpinner(`Configuration key '${key}' does not exist.`);
      return;
    }
    delete config[key];                  // modifies LOCAL object — NEVER persisted
    this.writeConfig(key, undefined);    // reads ANOTHER fresh config from disk
    this.succeedSpinner(`Configuration successfully reset`);
}

Impact

The delete config[key] on line 47 is dead code — it modifies
a local variable that is immediately discarded. writeConfig
then reads a completely fresh copy from disk anyway. This suggests
a logic misunderstanding that could cause real bugs if someone
refactors this code expecting the delete to have been persisted.

Suggested Fix

reset(key: string): void {
    const config = this.getConfig();
    if (!(key in config)) {
      this.failSpinner(`Configuration key '${key}' does not exist.`);
      return;
    }
    // Remove dead code - writeConfig handles persistence
    this.writeConfig(key, undefined);
    this.succeedSpinner(`Configuration successfully reset`);
}

File

src/commands/config/getSetReset.ts lines 38-50
Severity: Medium

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