Skip to content

fix(metadata): confirm deletion before resolving client and token - #214

Merged
synackd merged 1 commit into
OpenCHAMI:mainfrom
anyingiit:fix-metadata-delete-confirm
Oct 23, 2026
Merged

synackd merged 1 commit into
OpenCHAMI:mainfrom
anyingiit:fix-metadata-delete-confirm

Conversation

@anyingiit

Copy link
Copy Markdown
Contributor

Requested by winshyon · project thread

Fixes #188

The four metadata * delete commands (defaults, group, instance, peer) created the metadata-service client in RunE and called rt.HandleToken at the top of runCore*. Both happened before the "Really delete?" prompt. With no base URI or token configured, they failed (exit 3) without ever prompting.

This PR moves the client creation and the token handling after the confirmation block. That matches runCoreBootBmcDelete and the other delete commands already covered by TestDeleteConfirm_DeclineBeforeClient. The runCore* functions no longer take the client as a parameter, the same as the boot delete commands. Nothing else in the repo calls them.

Testing

  • Added metadata defaults/group/instance/peer cases to TestDeleteConfirm_DeclineBeforeClient in cmd/prompts_test.go.
    • Without the change, all 4 new cases fail.
    • With it, they pass.
  • go test ./...: all packages pass.
  • golangci-lint run ./... (v2.15.0, as in CI): 0 issues.
  • Manual check, reproducing the issue:
    $ echo n | ochami --ignore-config metadata peer delete id1
    Really delete? [yn]: ... WRN ... user aborted WireGuard peer deletion
    exit=8
    $ ochami --ignore-config metadata peer delete --no-confirm id1
    ... ERR ... base URI for metadata-service not found ...
    exit=3
    

The commit is signed off (DCO).

This change was prepared with AI assistance (Claude Code). I reviewed the diff and ran the tests above myself.

🤖 Generated with Claude Code

The metadata defaults, group, instance, and peer delete commands created
the metadata service client and handled the access token before asking
"Really delete?". Without a base URI or token they failed with an
unrelated error instead of prompting, unlike the other delete commands.

Prompt first, then create the client and handle the token, the same
order as the boot, bss, cloud-init, and smd delete commands. Add the four
commands to TestDeleteConfirm_DeclineBeforeClient.

Fixes OpenCHAMI#188

Signed-off-by: anyingiit <49945850+anyingiit@users.noreply.github.com>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-22T21:21:57.095911Z 1e6304f PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@synackd
synackd merged commit 5688632 into OpenCHAMI:main Oct 23, 2026
14 checks passed
@synackd synackd mentioned this pull request Oct 23, 2026
10 of 17 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] metadata * delete builds its client and checks the token before prompting

2 participants