question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

<InMemoryUploadedFile: logo_Reverse.svg (image/svg+xml)> is not JSON serializable ... but other uploads work fine.

See original GitHub issue

I have made file uploads before, and they work. However here i must have found a bug in graphene-file-upload.

{"errors":[{"message":"<InMemoryUploadedFile: Welnity_logo_Reverse.svg (image/svg+xml)> is not JSON serializable"}]}

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:9

github_iconTop GitHub Comments

1reaction
ungarocommented, Jul 27, 2019

@Thousif-S I would do following to resolve this issue:

1-Remove the VersatileImageFieldFile from your Mutation. Test it from the graphql view with arguments. Does it work now? 2 Change the VersatileImageFieldFile to ImageField. Test it from the graphql view with arguments. Does it work now?

Unfortunately graphene-file-upload hides the real error, so that makes you think that it’s related to graphene-file-upload, but in the end it was another error that i was not aware of.

In my case it was related to another field expecting different type of argument.

1reaction
japrogramercommented, May 11, 2019

it means that you are not passing an expected input. like in my previous comment shows the actual error is

hidden by graphene-file-upload
in my instance i was missing the position
class JobInput(InputProto):
    anonymous = graphene.Boolean()
    title = graphene.String()
    attachment = Upload(required=False)
    new_categories = graphene.List(graphene.String)

    class Meta:
        model = Job
        fields = (
            'hidden',
            'description',
            'location',
            'organization',
            'title',
            'position',
            'application_link',
            )
        _generic = {'required': False}
        fields_kwargs = {
            'location': _generic,
            'hidden': _generic,
            }

...

class CreateJob(graphene.Mutation):
    status = graphene.Int()
    errors = generic.GenericScalar()

    class Arguments:
        details = JobInput(required=True)

Read more comments on GitHub >

github_iconTop Results From Across the Web

Object of type InMemoryUploadedFile is not JSON ...
this error only occurs in mutations that have an upload file and some required field is missing due to mutation input. Graphene throws...
Read more >
Object of type InMemoryUploadedFile is not JSON ...
Here I am trying to update data in the bookmark model, But there is an error, related to image fields,. models.py
Read more >
Django object is not JSON serializable
I have the following code for serializing the queryset; def render_to_response(self, context, ** ... both django objects and dicts.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found