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

Cannot read property 'nodes' of undefined #93

Closed
arthurvasconcelos opened this issue May 23, 2019 · 14 comments
Closed

Cannot read property 'nodes' of undefined #93

arthurvasconcelos opened this issue May 23, 2019 · 14 comments
Labels

Comments

@arthurvasconcelos
Copy link

After login and select one repo to show in monitor tab it just returns this error message:

Error
Cannot read property 'nodes' of undefined

Your Version of Pullp

2.1.1

Your OS

Windows 10 Pro - Insider Preview - Build 18898.rs_prerelease.190510-1634

Expected Behavior

From what I took in the readme screenshots it should show me a monitor widget of my repo.

Current Behavior

It's just showing an error message.
2019-05-23

Steps to Reproduce (for bugs)

  1. Login in
  2. Select one repo
  3. Change to Monitor tab

Console Errors

react-dom.production.min.js:151

TypeError: Cannot read property 'nodes' of undefined
    at Object.children (index.js:160)
    at n (react-apollo.browser.umd.js:462)
    at t.render (react-apollo.browser.umd.js:466)
    at f (react-dom.production.min.js:131)
    at beginWork (react-dom.production.min.js:138)
    at i (react-dom.production.min.js:176)
    at a (react-dom.production.min.js:176)
    at w (react-dom.production.min.js:182)
    at g (react-dom.production.min.js:181)
    at v (react-dom.production.min.js:181)

index.js:13

TypeError: Cannot read property 'nodes' of undefined
    at Object.children (index.js:160)
    at n (react-apollo.browser.umd.js:462)
    at t.render (react-apollo.browser.umd.js:466)
    at f (react-dom.production.min.js:131)
    at beginWork (react-dom.production.min.js:138)
    at i (react-dom.production.min.js:176)
    at a (react-dom.production.min.js:176)
    at w (react-dom.production.min.js:182)
    at g (react-dom.production.min.js:181)
    at v (react-dom.production.min.js:181)

index.js:14

{componentStack: "↵    in t↵    in t↵    in t↵    in a↵    in t↵    …withRouter(t)↵    in t↵    in t↵    in t↵    in t"}
@rkclark rkclark added the bug label May 23, 2019
@rkclark
Copy link
Owner

rkclark commented May 23, 2019

Thanks for reporting this Arthur, not an issue I have seen before... Will have a look now.

@rkclark
Copy link
Owner

rkclark commented May 23, 2019

I wonder if its something to do with your organisation igarape-inc not having authorized the app (see the GraphQL error near the top of the console). Is the repo that you selected one that belongs to this organisation? If not and its public, please can you link to the repo so I can try to monitor it myself?

@arthurvasconcelos
Copy link
Author

arthurvasconcelos commented May 23, 2019

Hi @rkclark, actually no, the repo I selected has nothing to do with this org. I selected one of my own creations vue-izitoast. 😃

If you need any other information please let me know 😄

@rkclark
Copy link
Owner

rkclark commented May 23, 2019

So I can monitor the repo using the Windows build! I therefore think this must be something to do with the error saying Error: Can't find field organizations [...] on object User. This is really weird as the organizations field should be retrievable for every Github user, even if its an empty array. I have a test account that I use for testing Pullp which has no organizations and it works fine.

Maybe the field is supposed to have an organization in it (igarape-inc) but because its restricted due to no authorization it has got itself into a strange state. Are you a member of any other organizations?

I think I will have to look at falling back to an empty array value when this field is not present 🤔

It might be difficult for me to test for real, would you be willing to try out a beta build if I put something together over the next few days?

monitor_working

@arthurvasconcelos
Copy link
Author

Currently, I am on 3 orgs:
Screenshot from 2019-05-24 14-00-31
but it seems that the only one causing problems is igarape-inc and I don't know why haha.

Yeah sure, I can test any beta you release 😃 just let me know what I can do to help 😉

@rkclark
Copy link
Owner

rkclark commented May 26, 2019

Hi again!

So, this is the Graphql query that Pullp uses to get the organizations and teams that you are in:

{
  viewer {
    id
    login
    organizations(last:100) {
      edges {
        node {
          id
          teams(last:100, userLogins: [$login]) {
            edges {
              node {
                id
                name
              }
            }
          }
        }
      }
    }
  }
}

To try to replicate your issue, I have used the Github Graphql explorer to make a similar query on your user account:

query { 
 	user(login: "arthurvasconcelos") {
    organizations(last: 10) {
      edges {
        node {
          name
          teams(last: 10, userLogins: ["arthurvasconcelos"]) {
            edges {
              node {
                name
              }
            }
          }
        }
      }
    }
  }
}

This successfully resolves to this data:

{
  "data": {
    "user": {
      "organizations": {
        "edges": [
          {
            "node": {
              "name": "Instituto Igarapé",
              "teams": {
                "edges": []
              }
            }
          },
          {
            "node": {
              "name": "igarape-inc",
              "teams": {
                "edges": []
              }
            }
          }
        ]
      }
    }
  }
}

This is strange as I can't think why Pullp's query (which is basically the same) is failing. Would you be able to go onto Github's Graphql explorer yourself, sign in, and then run this query to see if it works?

{
  viewer {
    id
    login
    organizations(last:100) {
      edges {
        node {
          id
          teams(last:100, userLogins: ["arthurvasconcelos"]) {
            edges {
              node {
                id
                name
              }
            }
          }
        }
      }
    }
  }
}

This will mimic what Pullp does as closely as possible so I would be interested to see the result.

I have encountered bugs with the Github Graphql API before, it may turn out this is one of them. Did you try signing into Pullp and selecting your repo more than once? If not, could you try that? On the Account screen you can sign out. If you can't get to that screen for any reason then if you open the console and enter window.localStorage.clear() then close and open the app you should find that you are signed out.

Thanks!

@arthurvasconcelos
Copy link
Author

@rkclark Hi, I executed the query you mentioned and there is really an error:

{
  "data": {
    "viewer": {
      "id": "MDQ6VXNlcjEyODY3Njg=",
      "login": "arthurvasconcelos",
      "organizations": {
        "edges": [
          {
            "node": {
              "id": "MDEyOk9yZ2FuaXphdGlvbjQwMzA1NzQ=",
              "teams": {
                "edges": [
                  {
                    "node": {
                      "id": "MDQ6VGVhbTM3MjU2Nw==",
                      "name": "Admin"
                    }
                  },
                  {
                    "node": {
                      "id": "MDQ6VGVhbTMxMjgyMDU=",
                      "name": "Staff"
                    }
                  },
                  {
                    "node": {
                      "id": "MDQ6VGVhbTMxMjgyMDg=",
                      "name": "Developers"
                    }
                  }
                ]
              }
            }
          },
          {
            "node": null
          }
        ]
      }
    }
  },
  "errors": [
    {
      "type": "FORBIDDEN",
      "path": [
        "viewer",
        "organizations",
        "edges",
        1,
        "node",
        "teams"
      ],
      "locations": [
        {
          "line": 9,
          "column": 11
        }
      ],
      "message": "Although you appear to have the correct authorization credentials,\nthe `igarape-inc` organization has enabled OAuth App access restrictions, meaning that data\naccess to third-parties is limited. For more information on these restrictions, including\nhow to whitelist this app, visit\nhttps://help.github.com/articles/restricting-access-to-your-organization-s-data/\n"
    }
  ]
}

@rkclark
Copy link
Owner

rkclark commented May 30, 2019

That's very helpful! Interesting how the API gives you different results because you are the viewer.

I'm pretty sure Pullp is erroring because of the node with value null. It will be expecting it to be an object with a teams array every time. Will make a build with a fix soon (am away for a long weekend though so might be a few days).

@rkclark
Copy link
Owner

rkclark commented Jun 12, 2019

@arthurvasconcelos hey!

Try this beta version: https://drive.google.com/open?id=1s-EOqdNgxhqUWcHEs394JlzbWYbH7MoW

It has a lot of changes that I am working on in a new major version so it looks a bit different to what you have seen before. I can see there are some broken icons in the Windows build but this is more to see if I have fixed your particular issue.

Let me know :)

Cheers!

@arthurvasconcelos
Copy link
Author

Hi @rkclark, sorry for this late answer! Yeah now it works =D

It doesn't break anymore but the repo is appearing 3 times in a row haha.

2019-06-17

But the problem of this issue is solved now =D

@rkclark
Copy link
Owner

rkclark commented Jun 18, 2019

@arthurvasconcelos haha ok! Thanks for testing it for me!

The duplicate repositories is a known issue that is in the current production version as well. It's actually the main thing holding back the beta I am working on as I want it to be fixed in the next release.

There is a way to resolve it - Go to the Select screen, wait a few seconds, then go back to Monitor. Might need to do it a couple of times.

I'm pretty sure it's caused by Apollo Client being in the middle of a request to get your watched repositories when you leave the Select screen. It doesn't handle it nicely and all sorts of bad stuff happens 😢

@arthurvasconcelos
Copy link
Author

@rkclark yeah this back and forth in the selection screen for a few seconds really solved the problem and one time it also cleaned completely my selected list but was just repeat the process and the list was back again.

@rkclark
Copy link
Owner

rkclark commented Jul 29, 2019

Hi mate, included this fix in a new release! https://github.com/rkclark/pullp/releases/tag/v3.0.0

@rkclark rkclark closed this as completed Jul 29, 2019
@arthurvasconcelos
Copy link
Author

@rkclark Hey thank you! =D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants