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
hevycli routine get <id> -o json > r.json, reshape to the update format {"routine": {...}}
hevycli routine update <id> --file r.json
- 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.
Summary
hevycli routine update <id> --file r.jsonexits non-zero with a misleading error even when the update succeeds server-side:Cause
The Hevy API's
PUT /v1/routines/{routineId}response wraps the routine in an array:{ "routine": [ { "id": "...", "title": "...", ... } ] }while
RoutineResponse.routineis typed as a singleapi.Routine, so unmarshalling fails after the write has already been applied.Repro
hevycli routine get <id> -o json > r.json, reshape to the update format{"routine": {...}}hevycli routine update <id> --file r.jsonroutine 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.Routinefor this endpoint) would fix it.Thanks for the tool — it's genuinely useful for driving Hevy from scripts/agents.