Skip to content

routine create fails to parse API response after accepting valid folder_id #2

Description

@garoldot

Environment

  • hevycli installed via Homebrew cask on macOS
  • Command run from terminal
  • API key configured and other commands work

Problem

hevycli routine create appears to accept a valid folder_id, but then fails with a response parsing error:

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

Observed behavior

  1. If folder_id is omitted or null, the API returns:

    [public-post-routine] Invalid routine folder id: undefined
    
  2. If an invalid folder ID like 1 is provided, the API returns:

    [public-post-routine] Invalid routine folder id: 1
    
  3. If a valid folder ID is provided, the request gets past folder validation, but hevycli crashes parsing the response with:

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

This suggests:

  • request payload is accepted
  • response schema from API may now return an array where hevycli expects a single object
  • or the client is decoding the wrong shape for the create response

Reproduction

Command:

hevycli -o plain routine create --file chest-next-workout.json

Example payload:

{
  "routine": {
    "title": "Next Chest Workout",
    "folder_id": 2607603,
    "notes": "Chest hypertrophy focus. Minimum standard: log the full session and beat at least one metric next time.",
    "exercises": [
      {
        "exercise_template_id": "79D0BB3A",
        "rest_seconds": 150,
        "notes": "2 warm-up sets, then 3 work sets. Leave 1-2 reps in reserve on the first two work sets.",
        "sets": [
          {"type": "warmup", "reps": 15},
          {"type": "warmup", "reps": 8},
          {"type": "normal", "reps": 10},
          {"type": "normal", "reps": 8},
          {"type": "normal", "reps": 6}
        ]
      },
      {
        "exercise_template_id": "07B38369",
        "rest_seconds": 90,
        "notes": "Controlled eccentric. Full range.",
        "sets": [
          {"type": "normal", "reps": 12},
          {"type": "normal", "reps": 10},
          {"type": "normal", "reps": 8}
        ]
      },
      {
        "exercise_template_id": "78683336",
        "rest_seconds": 75,
        "notes": "Stretch and squeeze. No sloppy reps.",
        "sets": [
          {"type": "normal", "reps": 15},
          {"type": "normal", "reps": 12},
          {"type": "normal", "reps": 12}
        ]
      },
      {
        "exercise_template_id": "392887AA",
        "rest_seconds": 60,
        "notes": "Take sets close to failure with clean form.",
        "sets": [
          {"type": "normal", "reps": 15},
          {"type": "normal", "reps": 12}
        ]
      }
    ]
  }
}

Expected behavior

  • Routine should be created successfully
  • CLI should print created routine details or at least succeed silently

Actual behavior

  • CLI returns a Go JSON unmarshal error after the request is accepted

Possible root cause

The API response shape for create may be returning:

  • routine: []
  • or another array/object layout that no longer matches the client struct:
    • RoutineResponse.routine api.Routine

Suggested fix

  • inspect raw response body for routine create
  • update the response struct to match current API behavior
  • ideally add a fallback parser for object/array compatibility

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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