Page MenuHomePhabricator

Error: json: cannot unmarshal array on running mw toolhub tools list
Closed, ResolvedPublicBUG REPORT

Description

Steps to replicate:

  1. Run mw toolhub tools list -vv

What happens?:

level=trace msg="mwcli: PersistentPreRun"
Error: json: cannot unmarshal array into Go struct field Tool.results.author of type string

What should have happened instead?:
A list of toolforge tools are returned

Environment
Go
go version

go version go1.18 windows/amd64

mwcli
go version mw

go1.16.9

mw version -vv

level=trace msg="mwcli: PersistentPreRun"
mw version 0.13.1 ( 2022-04-28T08:07:30Z )
https://gitlab.wikimedia.org/repos/releng/cli/-/releases
level=debug msg="GitCommit: d6ab571\n\t\t\tGitBranch: HEAD\n\t\t\tGitState: clean\n\t\t\tGitSummary: v0.13.1\n\t\t\tBuildDate: 2022-04-28T08:07:30Z\n\t\t\tVersion: 0.13.1\n\t\t\t"

mw config show:

level=trace msg="mwcli: PersistentPreRun"
{
  "dev_mode": "docker",
  "telemetry": "yes",
  "_timer_last_emmited_event": "2022-05-21T15:47:38Z",
  "_timer_last_update_checked": "2022-05-21T15:47:38Z"
}

mw update -vv:

level=trace msg="mwcli: PersistentPreRun"
level=debug msg="Current version is: 0.13.1\nLatest available is: 0.13.1"
No update available

Event Timeline

Am I right in thinking that's caused by /internal/toolhub/tools.go#L23

type Tool struct {
	Name                 string        `json:"name"`
	Title                string        `json:"title"`
	Description          string        `json:"description"`
	URL                  string        `json:"url"`
	Keywords             []string      `json:"keywords"`
	Author               string        `json:"author"`
[snip]

expecting https://toolhub.wikimedia.org/api/tools/ to return something like

"author": "A Name",

instead of

"author": [
    {
        "name": "A Name"
    }
],

Yup, seems like changing that to

type Tool struct {
	Name                 string        `json:"name"`
	Title                string        `json:"title"`
	Description          string        `json:"description"`
	URL                  string        `json:"url"`
	Keywords             []string      `json:"keywords"`
	Author               []interface{} `json:"author"`
[snip]

resolves the issue 😸

Have filed a GitLab PR, no idea how y'all use that and link it to phab tasks etc.....

Addshore reassigned this task from Addshore to TheresNoTime.
Addshore added a project: Patch-For-Review.
Addshore moved this task from Inbox to Review on the mwcli board.
Addshore subscribed.

Thanks
I'll try and review the patch today :)

New patch

(also, did a tiny bit of figuring out how to use the GitLab API to implement a gerritbot-ish thing before realising how long I'd been shaving that yak.)

(also, did a tiny bit of figuring out how to use the GitLab API to implement a gerritbot-ish thing before realising how long I'd been shaving that yak.)

You might be interested in T265617: Experiment with GitLab-Phabricator integration for that :)

MR merged, and will be fixed in the next release

(also, did a tiny bit of figuring out how to use the GitLab API to implement a gerritbot-ish thing before realising how long I'd been shaving that yak.)

That would be awesome.

This will be in v0.14.0, which is currently building for release