cli icon indicating copy to clipboard operation
cli copied to clipboard

Fix `store addons`

Open scop opened this issue 3 years ago • 1 comments

Without this:

~ $ ha store addons
json: cannot unmarshal array into Go struct field Response.data of type map[string]interface {}

Plain ha store works and is the same, but as the addons subcommand exists, I suppose we should make it work, too.

scop avatar Aug 17 '22 04:08 scop

That is an bug at supervisor

pvizeli avatar Aug 23 '22 14:08 pvizeli

@pvizeli you're right but changing this in supervisor would break the frontend. Since we'd have to change this to return a dictionary and that's a breaking change in the API.

I looked into supporting the API as is in the CLI and honestly I don't think we can. We can make a ResponseList struct and a ShowJSONResponseList helper but it will break doubly on errors. The problem is data is only a list if the response is successful, if status is error then data will have an object and fail to unmarshal.

I think we have two workaround options here for now:

  1. Merge this PR. Possibly adjust it first to pull out the addons field from the response intead of simply showing it but that might be more effort then its worth.
  2. Add a new parameter to /store/addons that causes it to return a dictionary response without changing the default response and breaking backwards compatibility

Either way we should follow that up with a breaking change plan to the supervisor API. So eventually we can remove the workaround and fix the API. But I think our process requires at least 6 months to make a change like that.

mdegat01 avatar Nov 14 '22 17:11 mdegat01

Closing as this is addressed with https://github.com/home-assistant/supervisor/pull/4589.

agners avatar Sep 29 '23 08:09 agners