Skip to content

Commit 6db2d04

Browse files
committed
refactor: set value validation errors report the key that was used, not the one the user supplied
1 parent 83992fb commit 6db2d04

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/commands/config/set.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,10 @@ export class Set extends ConfigCommand<SetConfigCommandResult> {
4242

4343
for (const name of Object.keys(parsed)) {
4444
const value = parsed[name] as string;
45+
let resolvedName = name;
4546
try {
46-
const resolvedName = this.configAggregator.getPropertyMeta(name)?.newKey ?? name;
47+
// this needs to be inside the try/catch because it can throw an error
48+
resolvedName = this.configAggregator.getPropertyMeta(name)?.newKey ?? name;
4749
if (!value) {
4850
// Push a failure if users are try to unset a value with `set=`.
4951
this.pushFailure(name, messages.createError('error.ValueRequired'), value);
@@ -79,7 +81,7 @@ export class Set extends ConfigCommand<SetConfigCommandResult> {
7981
}
8082
}
8183
} else {
82-
this.pushFailure(name, err as Error, value);
84+
this.pushFailure(resolvedName, err as Error, value);
8385
}
8486
}
8587
}

0 commit comments

Comments
 (0)