Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
avm99963 opened this issue Feb 24, 2024 · 1 comment · May be fixed by #53
Open

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

avm99963 opened this issue Feb 24, 2024 · 1 comment · May be fixed by #53

Comments

@avm99963
Copy link

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:

// Returns the CL description.
//
// Requires detailed information (see fetchReviews).
getDescription() {
if (this.description_ === null) {
this.description_ = new Description(
this.getCurrentRevision().toJSON().commit.message);
}
return this.description_;
}

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 added a commit to avm99963/gerrit-monitor that referenced this issue Feb 24, 2024
When a CL doesn't have revisions, the current revision can't be found
and thus we can't retrieve the current revision's description.

This CL fixes this by returning null in getDescription() when this
happens, and falling back to the change's subject in the CL widget.

Fixes sdefresne#52
avm99963 added a commit to avm99963/gerrit-monitor that referenced this issue Feb 24, 2024
When a CL doesn't have revisions, the current revision can't be found
and thus we can't retrieve the current revision's description.

This CL fixes this by returning null in getDescription() when this
happens, and falling back to the change's subject in the CL widget.

Fixes sdefresne#52
@avm99963 avm99963 linked a pull request Feb 24, 2024 that will close this issue
@avm99963
Copy link
Author

I mailed a PR with my suggestion in case we find it useful: #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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant