Skip to content

routine update: false NETWORK_ERROR — update response returns routine as an array #6

Description

@ntonthat-easygo

Summary

hevycli routine update <id> --file r.json exits non-zero with a misleading error even when the update succeeds server-side:

failed to update routine: NETWORK_ERROR: failed to update routine: json: cannot unmarshal array into Go struct field RoutineResponse.routine of type api.Routine

Cause

The Hevy API's PUT /v1/routines/{routineId} response wraps the routine in an array:

{ "routine": [ { "id": "...", "title": "...", ... } ] }

while RoutineResponse.routine is typed as a single api.Routine, so unmarshalling fails after the write has already been applied.

Repro

  1. hevycli routine get <id> -o json > r.json, reshape to the update format {"routine": {...}}
  2. hevycli routine update <id> --file r.json
  3. Observe the NETWORK_ERROR — then routine get <id> shows the update was applied.

Verified on v0.3.0 (Homebrew cask, macOS arm64).

Impact

Scripts can't trust the exit code for updates — success is indistinguishable from failure without a follow-up get. A union/array-tolerant unmarshal (or decoding into []api.Routine for this endpoint) would fix it.

Thanks for the tool — it's genuinely useful for driving Hevy from scripts/agents.

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