Chef capture can not unmarshal array

Hey All,

I am attempting to run chef capture [NODE_NAME] -p [PROFILE] on a simple node to upgrade from Chef 13 to 18. (Upgrade Lab: Chef Infra Client 12 to latest)

I get an error that seems to be with any cookbook which has gems with versions defined in metadata.json. Cookbooks which have gems defined without versions are pulling down into the created directory fine. For those with the versions defined, I get this:

Error: unable to capture node cookbooks for '[NODE_NAME]': Failed to download cookbook [ERRANT_COOKBOOK_NAME] v[VERSION]: json: cannot unmarshal array into Go struct field CookbookMeta.metadata.gems of type string

(scrubbed data in brackets)

The difference in format for the various types of metadata.json is:
with no gems defined:

  "gems": [

  ],

With Gems but without versions pinned:

  "gems": [
    [
      "gem-0-name"
    ],
    [
      "gem-1-name"
    ]
  ],

With gems and versions:

  "gems": [
    [
      "gem-0-name",
      "~> 3"
    ],
    [
      "gem-1-name",
      "= 3.47.0"
    ]
  ],

EDIT: It's worth noting that I am not being prompted to pick a cookbook location as indicated in Upgrade Lab: Chef Infra Client 12 to latest . I believe it is trying to download them all from the infra server, but I do have our custom cookbooks locally for refactoring as needed. There still exist upstreams that I do not control and pulling them locally would be very tedious and error prone as the versions differ between nodes.

Any thoughts on how to proceed? Some of these are upstreams that I don't control, so removing the version pins isn't possible. Is this just a bug in Chef Workstation?

For anyone dealing with this it appears to have been a bug in the go-chef dependency of Chef Analyze. that was fixed in 0.28.1, so I've opened the issue here: Chef capture fails to unmarshal gems with versions: Bump go-chef to 0.28.1 · Issue #940 · chef/chef-analyze · GitHub to bump chef-analyze and then we can subsequently bump the version of chef-analyze in workstation.

1 Like