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

Empty results in reply.readAll() when receiving response from Core REST API #7335

Closed
kozlovsky opened this issue Mar 24, 2023 · 3 comments
Closed

Comments

@kozlovsky
Copy link
Contributor

Sometimes reply does not contain any data (see #7297, #7333). The actual reason for this is currently unclear.

It is possible that sometimes Core REST API actually returns an empty result, although it should not do this. All results from REST API are returned in JSON format, and even if the result by error does not contain any keys and is an empty dict, it is still not empty when serialized as a string: "{}".

Even when request processing leads to an error, the result should not be an empty string - it should still be a JSON dictionary with an "error" key that describes the error.

Another possibility is Core correctly returns the result, but on the GUI side, the QNetworkReply instance is garbage collected before reply.readAll() was called. Looking at the code, it is hard to say how it is possible as:

  1. The reference to the QNetworkReply instance is held by the QNetworkRequest instance.
  2. The reference to the QNetworkRequest instance is added to the RequestManager.active_requests set.
  3. The reference to the QNetworkRequest instance should be removed from the RequestManager.active_requests set only at the end of the Request.on_finished method when reply.readAll() should be already called.

The problem does not look critical, as it only happens sometimes. It can probably be ignored, but I created the issue so we can refer to this problem later.

@qstokkink
Copy link
Contributor

In addition to what you listed, this may be a case of needing to check self.reply.error() == QtNetwork.QNetworkReply.NoError before reading the value in self.reply.readAll() (there are many different intermittent errors that can occur in QNetworkReply itself).

@kozlovsky
Copy link
Contributor Author

@qstokkink thank you for this info, I'll add handling of QNetworkReply error codes in #7334

@kozlovsky
Copy link
Contributor Author

Should be fixed in #7334

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

No branches or pull requests

2 participants