"Cannot read properties of undefined (reading 'replace')" when using GitHub resource in a workflow

I'm trying to use a GitHub resource in a workflow, but the only response I can coax out of it is the error:

Cannot read properties of undefined (reading 'replace')

The same resource and query work fine if I use them in an app rather than a workflow. What do I need to be doing differently?

Hey Ben, mind sharing the query/output?

Probably what is happening it's the value that you are trying to replace is nullish and that is causing the error.

If it is supposed to be null in some cases you can add optional chaining in front of replace ?.

i.e.

something.value?.replace('x','y')

Hi Stefan,

First, I apologize -- this is using the GitHub resource, not the generic GraphQL resource that I indicated above.

I've tried it a few different ways; here's the most recent:

query {
  organization(login: "foo") {
    repository(name: "bar") {
      pullRequests(labels: ["baz"], first: 100) {
        nodes {
          number
          title
          state
          url
        }
      }      
    }
  }
}

Expected response (what I get in an app):

{
  "data": {
    "organization": null
  },
  "errors": [
    {
      "type": "NOT_FOUND",
      "path": [
        "organization"
      ],
      "locations": [
        {
          "line": 2,
          "column": 3
        }
      ],
      "message": "Could not resolve to an Organization with the login of 'foo'."
    }
  ]
}

Workflow response:

Error
Cannot read properties of undefined (reading 'replace')

I'm sure someone from Retool team will jump in to assist - as without full context I'm unable to assist.

I can only guess that one of foo/bar/baz values you're passing to that query block is null thus why causing the error with .replace function.

In this case, I'm using the actual string literals 'foo', 'bar', and 'baz'. Same resource, same query; in the app it returns the expected response, in workflows it dies. There are no variables, headers, transforms, or anything else, and it's the same environment in both contexts. From the browser network tab when I have the workflow open, I can see that no request is being sent, so the error appears to happen before the request is made.

Workflow:
Screenshot from 2023-05-19 08-17-14

App:

Perhaps @victoria could assist :wave:

I'm getting a similar issue trying to run a graphql query in a workflow as well. The same query works in the query library without trouble.

Hey @nmajor and @Ben_Reece! This repros on my end as well and I've filed a bug - the dev team will take a closer look into it. Were you able to get the GitHub resource working for you before? When did you first notice this not working?

Also thanks for exploring this and flagging us @stefancvrkotic :slightly_smiling_face:

As a workaround, can you try adding the same query to the query library and importing it from there?

Were you able to get the GitHub resource working for you before? When did you first notice this not working?

This was my first attempt at using it in a workflow, the same day I reported it (about a week ago), so I never had it work, I guess.

As a workaround, can you try adding the same query to the query library and importing it from there?

That does seem to work. I'll do that for now. Thank you!

Hey folks! Just want to report back here that this should be fixed!

2 Likes

Can confirm. Works now. Thanks Retool Team.