Skip to content
This repository has been archived by the owner on Feb 4, 2025. It is now read-only.

[Bug] Add null check if response is null. #3027

Merged
merged 2 commits into from
Jun 4, 2024
Merged

Conversation

notandyvee
Copy link
Contributor

@notandyvee notandyvee commented May 31, 2024

Issue

What

This PR fixes a bug where fetching the revision history of a post can possibly be null. I'm not clear on how it's possible. But forced a null revisionsResponseToRevisionsModel and can reproduce the crash. The simplest solution is to null check. Outside of that, I could not reproduce the crash organically.

Test

Copy link
Member

@irfano irfano left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May I suggest a different approach? If the response is null, onResponse() in the listener of fetchRevisions() can return BaseNetworkError(INVALID_RESPONSE). This way, the user can understand that there is an error instead of seeing an empty revision list.
You can see a similar solution in fetchSites() method.

@notandyvee
Copy link
Contributor Author

Very useful @irfano . Thank you for pointing out a good error. It wasn't obvious in the file, at least that I could see. The base error case is a nice compromise.

Copy link
Member

@irfano irfano left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! LGTM! 👍🏻

@irfano irfano merged commit 47aa870 into trunk Jun 4, 2024
14 checks passed
@irfano irfano deleted the andy/fluxc-issue-3024 branch June 4, 2024 07:18
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants