Skip to content

Commit 1f5d4f6

Browse files
jdxclaude
andcommitted
fix(set): don't skip value prompt when -k combined with metadata flags
When -k was combined with metadata flags like -d without an explicit value, has_metadata was true so the value prompt was skipped, silently discarding the -k flag. Now -k prevents the metadata-only skip path. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 4def388 commit 1f5d4f6

2 files changed

Lines changed: 14 additions & 1 deletion

File tree

src/commands/set.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ impl SetCommand {
6565
let secret_value = if let Some(ref v) = self.value {
6666
// Value provided as argument
6767
Some(v.clone())
68-
} else if has_metadata {
68+
} else if has_metadata && self.key_name.is_none() {
6969
// Only metadata is being set, no secret value needed
7070
None
7171
} else if !atty::is(atty::Stream::Stdin) {

test/set_key_name.bats

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,16 @@ teardown() {
5151
# key_name is silently ignored for encryption providers — it should not appear in config
5252
assert_file_not_contains test-config.toml "custom-key-name"
5353
}
54+
55+
@test "fnox set -k combined with -d still prompts for secret value" {
56+
# When -k is combined with metadata flags like -d, the secret value should
57+
# still be read (not skipped by the metadata-only path)
58+
run bash -c 'echo "my-secret-value" | "$FNOX_BIN" --config test-config.toml set -p age -k custom-key-name -d "my description" MY_SECRET'
59+
assert_success
60+
61+
# The config should reference the secret with description and encrypted value
62+
assert_file_contains test-config.toml "MY_SECRET"
63+
assert_file_contains test-config.toml "my description"
64+
# The plaintext secret value should NOT appear (it should be encrypted)
65+
assert_file_not_contains test-config.toml "my-secret-value"
66+
}

0 commit comments

Comments
 (0)