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

TypeError when accessing "variants" property of "Submission" object #215

Open
MrFrankenstein opened this issue Sep 11, 2021 · 2 comments
Open

Comments

@MrFrankenstein
Copy link

Got the following exception message while accessing variants property of a Submission object from my SubmissionPost class:

The following _TypeError was thrown building SubmissionPost(dirty):
type 'Null' is not a subtype of type 'String'
When the exception was thrown, this was the stack
#0      new SubmissionPreview._fromMap
package:draw/…/models/submission_impl.dart:491
#1      Submission.variants
package:draw/…/models/submission_impl.dart:254

Additionally, I have also found that this happens only when the variants field from the JSON object is not empty

@SupremeDeity
Copy link
Contributor

SupremeDeity commented Sep 19, 2021

#216 fixes this. I no longer use DRAW so do any follow-up if required using a PR.

Firstly, DRAW is based on PRAW and from my knowledge PRAW no longer contains the thumbnail or variants fields. The reason is that these are provided dynamically and thus the only way to access them in PRAW now is by the using the raw object. As such i have no idea why this is even present in DRAW.

Secondly:

Additionally, I have also found that this happens only when the variants field from the JSON object is not empty

This is because the line causing the error is only called when a variant is present.

Thirdly, the cause of the error:
From a quick look the code is trying to do this:

late String _id;

// later on
_id = map['id']; // this is a map containing all the variant data

Now the problem is that there is no id field in the JSON object. The only fields present are source and resolutions.

Temporary Fix:
use the data field to manually get the object and parse it yourself
OR
until the PR that i provided gets merged, clone my branch preview-fix branch and use it instead.

@bkonyi
Copy link
Member

bkonyi commented Sep 21, 2021

If thumbnail and variants aren't present anymore in Reddit's response, we should just remove them. Either way, thanks for submitting a PR, I'll take a look.

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

No branches or pull requests

3 participants