sdefresne / gerrit-monitor

Source for Gerrit Monitor Chrome extension
Apache License 2.0
21 stars 16 forks source link

Error when a change doesn't have any revision #52

Open avm99963 opened 8 months ago

avm99963 commented 8 months ago

My Gerrit server is answering API requests to /changes/ with some changes which have the revisions property empty:

)]}'
[
  [
    {
      // The |current_revision| property is missing.

      // And |revisions| contains an empty object:
      "revisions": {},

      // ...
    }
  ]
]

This is due to an incomplete/incorrect index, since I just restarted my Gerrit instance and I guess I did it at the worst time. Running gerrit index changes {ID} to reindex the changes affected by this fixed the issue.

When this error occurs, the popup doesn't show any CLs but instead shows the following error: TypeError: Cannot read properties of undefined (reading 'commit'). The error occurs here:

https://github.com/sdefresne/gerrit-monitor/blob/5d72c67de692ea484491936085d21278d29deb89/src/gerrit.js#L337-L346

Maybe we can consider returning null if there aren't any revisions? And then in the CL widget, we could show the subject as a fallback if the description is null.

avm99963 commented 8 months ago

I mailed a PR with my suggestion in case we find it useful: https://github.com/sdefresne/gerrit-monitor/pull/53

I tested the change by running http-server -p 8081 in the folder I attach compressed (which simulates a Gerrit server with this issue) and adding http://localhost:8081 to the extension options.

📎 gerrit-monitor-issue-53.tar.gz