fix(set): preserve existing remote key name - #712
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository YAML (base), Central YAML (inherited), Organization UI (inherited) Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe set command resolves remote keys from the write target and profile. It reuses compatible target-owned keys and falls back to the environment key. Vault now supports field-specific secret updates. Tests cover key resolution, GCP cleanup, and Vault field preservation. ChangesRemote key and Vault updates
Estimated code review effort: 3 (Moderate) | ~25 minutes Mergeability Score: ⚪ Minimal · up to This change preserves configured remote key names when updating secrets and adds related provider coverage; no actionable merge-blocking risk remains after normal checks and review. Sequence Diagram(s)sequenceDiagram
participant User
participant SetCommand
participant WriteProfile
participant RemoteProvider
participant VaultCLI
User->>SetCommand: invoke fnox set
SetCommand->>WriteProfile: resolve target and provider
SetCommand->>RemoteProvider: resolve compatible remote key
SetCommand->>VaultCLI: write whole secret or selected field
VaultCLI-->>SetCommand: return write result
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Greptile SummaryThe PR preserves existing remote key names during
Confidence Score: 4/5The PR is not yet safe to merge because permanently destroyed Vault field references still cannot be recreated. The recovery path classifies destroyed KV v2 versions as soft-deleted and attempts a CAS write against the destroyed current version, after which the fallback patch still targets a missing secret. Files Needing Attention: crates/fnox-core/src/providers/vault.rs, test/vault.bats Important Files Changed
Reviews (8): Last reviewed commit: "fix(deps): stabilize windows mise setup" | Re-trigger Greptile |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
src/commands/set.rs (1)
368-409: 🗄️ Data Integrity & Integration | 🔵 Trivial | 🏗️ Heavy liftCover the command wiring, not only the helper.
These tests call
resolve_remote_key_namedirectly. They do not verify thatSetCommand::runselects the existing provider, passes the resolved name toput_secret, and persists the name during an update. Add a mocked-provider regression test for an existing same-provider secret and a dry-run update.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/commands/set.rs` around lines 368 - 409, Add regression tests covering SetCommand::run command wiring, not just resolve_remote_key_name: mock the provider for an existing same-provider secret and verify the selected provider and resolved name are passed to put_secret, then add a dry-run update case verifying the resolved name is persisted without performing the write. Reuse the existing test helpers and provider-mocking symbols in the module.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/commands/set.rs`:
- Around line 109-115: Update the provider-resolution logic in the set command
around existing_secret and provider_name_to_use to use the effective
write-profile selected by --write-profile, rather than the active --profile.
Apply that write-profile scope to both existing-secret and provider lookups
while preserving explicit --provider behavior, and add a regression test
covering distinct --profile and --write-profile values.
---
Nitpick comments:
In `@src/commands/set.rs`:
- Around line 368-409: Add regression tests covering SetCommand::run command
wiring, not just resolve_remote_key_name: mock the provider for an existing
same-provider secret and verify the selected provider and resolved name are
passed to put_secret, then add a dry-run update case verifying the resolved name
is persisted without performing the write. Reuse the existing test helpers and
provider-mocking symbols in the module.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository YAML (base), Central YAML (inherited), Organization UI (inherited)
Review profile: CHILL
Plan: Pro Plus
Run ID: e1570743-7a11-4bcf-8fbe-f61e3ce4fbd9
📒 Files selected for processing (2)
src/commands/set.rstest/gcp_secret_manager.bats
Instruction counts
No instruction-count regression above 1.25%. Only instruction counts gate. Wall clock is shown for context — on identical hardware it moves 4-20% run to run. Measured by tak — instruction-counted CLI benchmarks, stored in this repository's git notes.
|
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@test/vault.bats`:
- Around line 136-159: Register failure-safe cleanup immediately after
create_test_vault_secret assigns secret_name, using the test’s established
teardown or trap mechanism to call delete_test_vault_secret with that name.
Ensure cleanup runs when any subsequent command or assertion in this test fails,
while preserving the existing final cleanup behavior without causing duplicate
deletion.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository YAML (base), Central YAML (inherited), Organization UI (inherited)
Review profile: CHILL
Plan: Pro Plus
Run ID: 6ec05def-142f-46a4-929c-fcf356c4987f
📒 Files selected for processing (4)
crates/fnox-core/src/providers/vault.rssrc/commands/set.rstest/set_remote_key.batstest/vault.bats
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@crates/fnox-core/src/providers/vault.rs`:
- Around line 252-257: Update the missing-secret fallback in the vault write
flow around execute_vault_command to use kv put with -cas=0, preventing
overwrite of a concurrently created secret. If that create-only write fails,
retry the original kv patch operation and propagate any resulting error. Add an
integration test covering the concurrent-creation race.
- Around line 251-260: Update the Vault write flow around execute_vault_command
to prevent secret values beginning with @ from being interpreted as file paths
and values equal to - from being read from process stdin. Escape leading @
values before constructing patch_args or put_args, and route - values through a
controlled stdin pipe; add regression tests covering both behaviors.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository YAML (base), Central YAML (inherited), Organization UI (inherited)
Review profile: CHILL
Plan: Pro Plus
Run ID: a2c33223-aa90-4fe5-a0f0-9857babb22c2
📒 Files selected for processing (2)
crates/fnox-core/src/providers/vault.rstest/vault.bats
🚧 Files skipped from review as they are similar to previous changes (1)
- test/vault.bats
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 251884f. Configure here.
### 🐛 Bug Fixes - **(set)** preserve existing remote key name by [@jdx](https://github.com/jdx) in [#712](#712) ### 📚 Documentation - fix sponsor logo sizing by [@jdx](https://github.com/jdx) in [#714](#714) ### 🛡️ Security - **(deps)** update dependency @anthropic-ai/claude-code to v2.1.221 by [@renovate[bot]](https://github.com/renovate[bot]) in [#705](#705) ### 📦️ Dependency Updates - simplify cargo version requirements by [@jdx](https://github.com/jdx) in [#694](#694) - update rust crate usage-lib to v5.1.0 by [@renovate[bot]](https://github.com/renovate[bot]) in [#695](#695) - update rust crate google-cloud-secretmanager-v1 to v1.12.0 by [@renovate[bot]](https://github.com/renovate[bot]) in [#706](#706) - update jdx/mise-action action to v4.2.4 by [@renovate[bot]](https://github.com/renovate[bot]) in [#697](#697) - update rust crate aho-corasick to v1.1.5 by [@renovate[bot]](https://github.com/renovate[bot]) in [#698](#698) - update rust crate data-encoding to v2.11.1 by [@renovate[bot]](https://github.com/renovate[bot]) in [#700](#700) - update rust crate clap to v4.6.5 by [@renovate[bot]](https://github.com/renovate[bot]) in [#699](#699) - update rust crate ignore to v0.4.32 by [@renovate[bot]](https://github.com/renovate[bot]) in [#701](#701) - update rust crate keepass to v0.13.20 by [@renovate[bot]](https://github.com/renovate[bot]) in [#702](#702) - update zizmorcore/zizmor-action action to v0.6.2 by [@renovate[bot]](https://github.com/renovate[bot]) in [#704](#704) - update rust crate rustls to v0.23.43 by [@renovate[bot]](https://github.com/renovate[bot]) in [#703](#703) - update rust crate base64 to v0.23.1 by [@renovate[bot]](https://github.com/renovate[bot]) in [#707](#707) - update rust crate globset to v0.4.20 by [@renovate[bot]](https://github.com/renovate[bot]) in [#708](#708) - update dependency @anthropic-ai/claude-code to v2.1.222 by [@renovate[bot]](https://github.com/renovate[bot]) in [#710](#710) - update rust crate ignore to v0.4.33 by [@renovate[bot]](https://github.com/renovate[bot]) in [#709](#709) - lock file maintenance by [@renovate[bot]](https://github.com/renovate[bot]) in [#715](#715)
Summary
fnox setupdates a secret--key-nameas the highest-precedence overrideRoot cause
fnox setreused the existing provider but resolved remote key names only from--key-nameor the environment key. It then persisted that fallback, replacing a customvaluein the config and writing to the wrong remote secret.Validation
mise run test:cargomise run lintmise run buildmise run test:bats -- test/gcp_secret_manager.bats(10 credential-gated tests skipped because GCP credentials are unavailable)Fixes #711
AI-assisted — Tool: Codex; model: openai/gpt-5; version: unavailable.
Note
Medium Risk
Changes how remote secrets are named and written on every
setfor storage providers, and Vaultput_secretnow has complex patch/CAS paths where a bug could corrupt or mis-route secret data.Overview
Fixes
fnox setso updates to remote-backed secrets keep the configured providervalue(custom remote key) instead of overwriting it with the env var name and writing to the wrong backend object.--key-namestill wins; switching providers falls back to the env key. Only secrets that belong to the file/profile being written supply that reuse—inherited parent config no longer steers a child override.HashiCorp Vault
put_secretis reworked:secret/fieldreferences,kv patchfor field updates (siblings preserved), values via piped stdin (so@and-are literal), plus create/retry/CAS handling for missing paths, races, and soft-deleted KV v2 metadata.CI: Windows
mise-actionsetsfetch_from_github: false. Newtest/set_remote_key.bats, expanded Vault BATS, and a GCP SM create test fix (generated secret name + cleanup).Reviewed by Cursor Bugbot for commit 34a6052. Bugbot is set up for automated code reviews on this repo. Configure here.
Summary by CodeRabbit
New Features
Bug Fixes