Skip to content

routine delete: exits 0 on cancellation; confirmed delete returns NOT_FOUND for listed routine #4

@asabirov

Description

@asabirov

Environment

  • hevycli version: dev (built from source)
  • OS: macOS (Apple Silicon)

Steps to reproduce

  1. hevycli routine list → routine "Back Day" (ID 75fa8ead-a1c4-4b25-bcd6-c452e9cbed83) is visible.
  2. Run hevycli routine delete 75fa8ead-a1c4-4b25-bcd6-c452e9cbed83, type nothing / cancel → exits 0 (expected: non-zero).
  3. Run the same command again, type yes to confirm → Error: failed to delete routine: NOT_FOUND: Resource not found, exits 1.

Bug 1 — Wrong exit code on cancellation

When the user declines the confirmation prompt, the command prints Deletion cancelled. but exits with code 0. A cancelled/no-op operation should exit non-zero so scripts can detect it.

Root cause: In cmd/routine/delete.go:104-107, the cancellation path returns nil, which Cobra treats as success (exit 0):

if response != "yes" {
    fmt.Println("Deletion cancelled.")
    return nil  // ← should return an error or use os.Exit(1)
}

Bug 2 — NOT_FOUND for a routine that appears in routine list

After confirming deletion with yes, the API returns NOT_FOUND. The routine was returned by hevycli routine list moments earlier.

Possible root causes:

  • The list endpoint (GET /v1/routines) and the delete endpoint (DELETE /v1/routines/{id}) may be using different ID semantics — e.g., the API may expect a different identifier format for mutations.
  • The list may be returning stale/cached data for a routine that no longer exists in the Hevy backend.
  • The GetRoutine call at delete.go:86 succeeds (so the routine exists for reads), but the DeleteRoutine call at delete.go:111 hits a different endpoint or applies different auth/permissions.

Both GetRoutine and DeleteRoutine in internal/api/client.go use the same path prefix (/routines/ + id), so the issue may be upstream in the Hevy API itself.

Expected behavior

  • Cancellation → non-zero exit code.
  • A routine visible in routine list should be deletable without a NOT_FOUND error.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions