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.

Unknown Argument ValueError Issue - Unable to Diagnose Cause

See original GitHub issue

I’ve been having issues with one of my passed mutation arguments that keeps triggering the middleware exception leak checker on graphiql interface load. Migrations and server start are just fine, but loading the url for the interface delivers a "ValueError at /graphql/ Unknown argument “assignee”. " error about.

The following are the directly relevant code snippets.

So I’ve build a “chores” model as such:

class Chore(models.Model):
    name = models.TextField(blank=True)              
    description = models.TextField(blank=True)
    isAllDay = models.BooleanField(blank=False)
    points = models.IntegerField(blank=False)
    status = models.IntegerField(blank=False, null=False)
    recurrence_pattern = models.IntegerField(null=False, blank=False)
    recurrence_enddate = models.DateTimeField(null=True, blank=False)
    deadline = models.DateTimeField(blank=False)
    created_by = models.ForeignKey(
        'users.User',
        related_name='chores_created',             
        on_delete=models.SET_NULL,
        null=True,
    )
    assigned_to = models.ForeignKey(
        'users.User',
        related_name='chores_assigned',          
        on_delete=models.SET_NULL,
        null=True,
    )
    belongs_to = models.ForeignKey(
        'households.Household',
        related_name="chores",
        on_delete=models.SET_NULL,
        null=True,
    )

Below is the relevant schema portion, including the Type decleration and the InputObjectType I’m utilizing within that same query. I’ve included these portions as I have a strong hunch that the “assignee” value has nothing to do with the actual error, alas, I cannot figure out what it may be.

class ChoreType(DjangoObjectType):
    class Meta:
        model = Chore

class ResourceCreateInput(graphene.InputObjectType):
    name = graphene.String(required = True)
    checked = graphene.Boolean(required = True)

class AddChore(graphene.Mutation):
    chore = graphene.Field(ChoreType)

    class Arguments:
        name = graphene.String(),
        description= graphene.String(),
        isAllDay= graphene.Boolean,
        points= graphene.Int(),
        status= graphene.Int(),
        recurrence_pattern= graphene.Int(),
        recurrence_enddate= graphene.DateTime(),
        deadline= graphene.DateTime(),
        creator= graphene.Int(),  # userid
        assignee= graphene.Int(),  # userid
        resources= graphene.List(ResourceCreateInput)



    def mutate(self, info, isAllDay, points, status, recurrence_pattern, recurrence_enddate, deadline, creator, assignee = None, resources = None, name = None, description = None):


        cUser = User.objects.filter(id=creator).first()
        if not cUser:
            raise GraphQLError('Invalid Link!')
        if assignee != None:
            aUser = User.objects.filter(id=assignee).first()
            if not aUser:
                raise GraphQLError('Invalid Link!')
        else:
            aUser = None
        household = Household.objects.filter(id = 1)
        chore = Chore(
            name = name,
            description = description,
            isAllDay = isAllDay,
            points = points,
            status = status,
            recurrence_pattern = recurrence_pattern,
            recurrence_enddate = recurrence_enddate,
            deadline = deadline,
            created_by = cUser,
            assigned_to = aUser,

        )
        chore.save()

        if resources != None:
            for x in resources: 
                resource = Resource(
                    name = x.name,
                    checked = x.checked,
                    assigned_to = Chore.objects.get(id__exact = chore.id)
                )
                resource.save()


        return AddChore(
            id = chore.id,
        )

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:18 (12 by maintainers)

github_iconTop GitHub Comments

1reaction
changelingcommented, May 26, 2019

Oh, and a big caveat here: This is only setting up CORS here, and CSRF consideration is important when you approach deploying to the wild. This is a good local development solution, but before you deploy, be absolutely sure to read up on both CORS and CSRF, and the security implications involved.

1reaction
changelingcommented, May 26, 2019

You should check it out in its current state, it’s about complete.

I’ll check it out!

I’m actually having a bit of a CORS error on the client side with a redirect issue going on. Here’s the error I’m getting: “Access to fetch at ‘http://localhost:8000/gql’ from origin ‘http://localhost:3000’ has been blocked by CORS policy: Response to preflight request doesn’t pass access control check: Redirect is not allowed for a preflight request.”.

I’m not positive, but you may be in luck. I just now solved my own CORS issues. I have not had a chance to test it live, but I’ve incorporated the changes I made to my own project which solved CORS being a jerk. I’ve submitted a PR to your project and you can try it out. Let me know if it works for you, but don’t see your frontend stuff in the repo, so can’t confirm or deny that it works.

NOTE: You might want to create a new branch to merge the PR into. If you do, and need me to redirect the PR, lemme know.

HEADS UP: You may need to play around with the CORS_ORIGIN_WHITELIST settings, but they’re currently handling my own React-Relay frontend just fine.

Also note that, in my Environment.js file, the network declaration looks like this:

  const network = Network.create((operation, variables) => {
    // 4
    return fetch('http://localhost:8004/graphql', {
      method: 'POST',
      credentials: 'include',
      headers: {
        'Accept': 'application/json',
        'Content-Type': 'application/json',
      },
      body: JSON.stringify({
        query: operation.text,
        variables
      }),
    }).then(response => {
      return response.json()
    })
  })

I hear you can fix that by using corsheaders in the venv but unfortunately my pip install django-cors-headers doesn’t actually generate a django-corsheaders in the venv and my entire thing fails to load.

Yeah, that’s one of those dmmit-it’s-named-differently package things. django-cors-headers installs corsheaders and not django-cors-headers, though I believe you should have django_cors_headers-3.0.1.dist-info somewhere in there. If you don’t see either one, double- and triple-check that you’re installing them with your venv activated, and not system-wide.

Could you give me a hand patching the last thing on?

Hand given. 😃 Maybe.

Last note: I’m happy, if I have time, to help on occasion, but from here forward, it’s prolly best if you contact me via github rather than in this issue, to avoid spamming here. I’m addressing this one because I’m just about to add the CORS thingie to the graphene-django wiki, so it seems to fit.

Cheers! And do let us know if this works or not. Pretty sure that’d be fine here.

Read more comments on GitHub >

github_iconTop Results From Across the Web

python - Graphene: ValueError: Unknown argument " ...
When i run the application I'm getting the following error: ...schema\__init__.py", line 33, in Mutation create_user = CreateUser. Field() ....
Read more >
Fix ValueError: Unknown label type: 'continuous' In scikit- ...
Essentially, the error is telling us that the type of the target variable is continuous which is not compatible with the specific model...
Read more >
Troubleshoot Python errors in Azure Functions
This error occurs when a Python function app fails to load a Python module. The root cause for this error is one of...
Read more >
Errors | Node.js v19.3.0 Documentation
If an object is passed as message , the text message is generated by calling String(message) . If the cause option is provided,...
Read more >
Trap and fix errors in your VLOOKUP in Google Sheets
Incorrect column number – #VALUE! error. Sometimes the third argument of Google Sheets VLOOKUP is indicated incorrectly.
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