etcinit/phabulous

json: cannot unmarshal array into Go value of type responses.PHIDLookupResponse

pdilyard opened this issue · 9 comments

Consistently getting this error:

ERRO[0003] json: cannot unmarshal array into Go value of type responses.PHIDLookupResponse 

I'm on the latest master branch of Phabricator, and I have tried both release 2.3.0 of Phabulous, as well as manually compiling the master branch. I got the same error from both.

I've been testing by sending the message "lookup T123" to the Phabulous bot, and it has resulted in the above error every time (and the bot responds with an error message in the chat).

Here's my configuration:

server:
  port: 8085
  debug: false

  # Serious-mode makes some messages more formal and business-friendly.
  serious: false
slack:
  token: REDACTED
  username: phabricator
conduit:
  api: REDACTED
  # For token-based auth, use the following key:
  token: REDACTED

  # For certificate-based auth, use the following keys:
  #user: etcinit
  #cert: ''
channels:
  # The feed channel is where Phabulous will post every feed event to this
  # channel. Leave it blank to disable this feature.
  #feed: '#phabricator'

  # You can map repositories to a channel. This will send feed events regarding
  # commits and revisions to the specified channel.
  #repositories:
  #  CALLSIGN: '#channel'
  #  OTHERCALLSIGN: '#otherchannel'

  # You can map projects to a channel. This will send feed events regarding
  # tasks to the specified channel.
  projects:
    17: '#development'
misc:
  ignore-ca: false

Oh and I did search through the issues before posting this, and found that #22 was the same, but that it had been closed as resolved. I wanted to report that it is not resolved, at least for me.

I'm also seeing this issue when trying to look up a task with lookup Txxxx

Turned out my bot didn't have permissions to view that task.

I've tried making my bot an administrator and I still get the same error. For me, it is also not specific to lookup Txxx

Hm. I'll try to give this a look soon. There are multiple reasons why this could be happening, like authorization or API changes. The main problem being that Gonduit did not got the expected response from Phabricator. Gonduit definitely needs some work on how it reports these issues. I'll open a task for providing a copy of the API response when errors occur (etcinit/gonduit#2).

Ok, the issue seems to be that Phabricator returns an empty array/object when the response is empty. Golang's JSON decoder parses this as an array, which cannot be converted to a map, hence the error above.

I have a fix on the works (ccfabc9) but I need to experiment a bit more.

Empty responses seem to happen when the bot doesn't have access to an object or the object simply does not exist.

Relevant Gonduit commit: etcinit/gonduit@162817d

This should be fixed in the upcoming 3.0.0 release.

Thanks!