CenterForOpenScience / osf.io

Facilitating Open Science
https://osf.io
Apache License 2.0
668 stars 329 forks source link

Selecting GitLab repository belonging to group prevents file browser from displaying files [OSF-9077] #8048

Closed vkehayas closed 6 years ago

vkehayas commented 6 years ago

After I enabled the GitLab add-on, the file browser stopped displaying my files. I only see a spinning wheel next to my projects name (see screenshot). Everything works fine if I disable the add-on by disconnecting the account but not if I do not select any GitLab repository. The issue appears in both Chrome and Firefox with no plugins/extensions enabled. Here are the errors from the console in Chrome:

jquery.min.js:2 jQuery.Deferred exception: Cannot read property 'branch' of undefined TypeError: Cannot read property 'branch' of undefined at o (https://osf.io/static/public/js/gitlab/files.8c0a241b61af243e576d.js:1:277) at n.s (https://osf.io/static/public/js/gitlab/files.8c0a241b61af243e576d.js:1:1156) at https://osf.io/static/public/js/vendor.5cdfb267d6a9e799e7c5.js:12:3405 at Array.map () at https://osf.io/static/public/js/vendor.5cdfb267d6a9e799e7c5.js:12:2989 at Array.map () at Object.m.view (https://osf.io/static/public/js/vendor.5cdfb267d6a9e799e7c5.js:12:1864) at Object.i [as view] (https://osf.io/static/public/js/vendor.5cdfb267d6a9e799e7c5.js:10:14496) at m (https://osf.io/static/public/js/vendor.5cdfb267d6a9e799e7c5.js:10:14809) at Function.r.redraw (https://osf.io/static/public/js/vendor.5cdfb267d6a9e799e7c5.js:10:21166) at n.refreshRange (https://osf.io/static/public/js/vendor.5cdfb267d6a9e799e7c5.js:11:23788) at n.calculateVisible (https://osf.io/static/public/js/vendor.5cdfb267d6a9e799e7c5.js:11:23521) at https://osf.io/static/public/js/vendor.5cdfb267d6a9e799e7c5.js:11:22169 at i (https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js:2:28017) at Object.add [as done] (https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js:2:28316) at n.toggleFolder (https://osf.io/static/public/js/vendor.5cdfb267d6a9e799e7c5.js:11:21076) at n.updateFolder (https://osf.io/static/public/js/vendor.5cdfb267d6a9e799e7c5.js:11:20706) at n.q (https://osf.io/static/public/js/vendor.5cdfb267d6a9e799e7c5.js:19:13248) at n.ondataload (https://osf.io/static/public/js/vendor.5cdfb267d6a9e799e7c5.js:20:532) at https://osf.io/static/public/js/vendor.5cdfb267d6a9e799e7c5.js:11:14315 at i (https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js:2:28017) at fireWith (https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js:2:28783) at j (https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js:2:30283) at k (https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js:2:30313) at c (https://osf.io/static/vendor/bower_components/raven-js/dist/raven.min.js:2:3899) undefined r.Deferred.exceptionHook @ jquery.min.js:2 k @ jquery.min.js:2 c @ raven.js:267 setTimeout (async) (anonymous) @ raven.js:641 (anonymous) @ jquery.min.js:2 i @ jquery.min.js:2 add @ jquery.min.js:2 (anonymous) @ jquery.min.js:2 Deferred @ jquery.min.js:2 then @ jquery.min.js:2 a @ treebeard.js:1667 m.controller @ treebeard.js:2051 n @ mithril.js:554 r.mount.r.module @ mithril.js:598 v @ treebeard.js:2702 _initGrid @ fangorn.js:2875 init @ fangorn.js:2871 ye @ fangorn.js:2861 (anonymous) @ files-page.js:18 i @ jquery.min.js:2 fireWith @ jquery.min.js:2 A @ jquery.min.js:4 (anonymous) @ jquery.min.js:4 c @ raven.js:267 XMLHttpRequest.send (async) (anonymous) @ raven.js:695 send @ jquery.min.js:4 ajax @ jquery.min.js:4 (anonymous) @ files-page.js:15 j @ jquery.min.js:2 k @ jquery.min.js:2 c @ raven.js:267 setTimeout (async) (anonymous) @ raven.js:641 (anonymous) @ jquery.min.js:2 i @ jquery.min.js:2 fireWith @ jquery.min.js:2 fire @ jquery.min.js:2 i @ jquery.min.js:2 fireWith @ jquery.min.js:2 ready @ jquery.min.js:2 S @ jquery.min.js:3 c @ raven.js:267 (index):1 The SSL certificate used to load resources from https://bam.nr-data.net will be distrusted in M70. Once distrusted, users will be prevented from loading these resources. See https://g.co/chrome/symantecpkicerts for more information.

Apparently, osf is unable to access the branch property. I have given osf full access to the GitLab api (api scope). Please let me know how I could provide more info if needed.

screenshot from 2017-12-14 12-17-36

mfraezz commented 6 years ago

I'm unable to reproduce this bug, but I'd still like to get to the bottom of it. I've looked through our error logging system but didn't find anything relevant.

@vkehayas, can you confirm whether or not the stack trace in the browser console is the same in both cases you described (account and repo connected, or just account connected), and if not, provide a trace for the other case? Particularly, the first two lines after the TypeError

Also, would you mind emailing your project's GUID (the 5-character string after osf.io/ when viewing your project) to support@osf.io so that we can investigate if the project's state is related?

vkehayas commented 6 years ago

Thank you for your prompt response.

After I disabled and re-enabled GitLab I was able to browse my files before selecting a GitLab repo and the stack trace was clean. After selecting a GitLab repo, I got the same trace as before. I realize that de-selecting the repo has no effect - upon page refresh the same repo is selected. I guess selecting ---- is not a valid option once you 've selected a repo.

I've sent an email with my GUID, as instructed.

mfraezz commented 6 years ago

Thanks, @vkehayas. I've diagnosed the bug, I expect we'll have a fix out later today. I'll keep this issue open until it's deployed

sloria commented 6 years ago

Thanks @mfraezz for the fix.

@vkehayas The fix is now deployed. Can you please verify that the issue is fixed?

vkehayas commented 6 years ago

No, sorry, I still get similar output.

jquery.min.js:2 jQuery.Deferred exception: Cannot read property 'branch' of undefined TypeError: Cannot read property 'branch' of undefined at o (https://osf.io/static/public/js/gitlab/files.8c0a241b61af243e576d.js:1:276) at n.s (https://osf.io/static/public/js/gitlab/files.8c0a241b61af243e576d.js:1:1156) at https://osf.io/static/public/js/vendor.5cdfb267d6a9e799e7c5.js:12:3405 at Array.map (native) at https://osf.io/static/public/js/vendor.5cdfb267d6a9e799e7c5.js:12:2989 at Array.map (native) at Object.m.view (https://osf.io/static/public/js/vendor.5cdfb267d6a9e799e7c5.js:12:1864) at Object.i [as view] (https://osf.io/static/public/js/vendor.5cdfb267d6a9e799e7c5.js:10:14496) at m (https://osf.io/static/public/js/vendor.5cdfb267d6a9e799e7c5.js:10:14809) at Function.r.redraw (https://osf.io/static/public/js/vendor.5cdfb267d6a9e799e7c5.js:10:21166) at n.refreshRange (https://osf.io/static/public/js/vendor.5cdfb267d6a9e799e7c5.js:11:23788) at n.calculateVisible (https://osf.io/static/public/js/vendor.5cdfb267d6a9e799e7c5.js:11:23521) at https://osf.io/static/public/js/vendor.5cdfb267d6a9e799e7c5.js:11:22169 at i (https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js:2:28017) at Object.add [as done] (https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js:2:28316) at n.toggleFolder (https://osf.io/static/public/js/vendor.5cdfb267d6a9e799e7c5.js:11:21076) at n.updateFolder (https://osf.io/static/public/js/vendor.5cdfb267d6a9e799e7c5.js:11:20706) at n.q (https://osf.io/static/public/js/vendor.5cdfb267d6a9e799e7c5.js:19:13248) at n.ondataload (https://osf.io/static/public/js/vendor.5cdfb267d6a9e799e7c5.js:20:532) at https://osf.io/static/public/js/vendor.5cdfb267d6a9e799e7c5.js:11:14315 at i (https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js:2:28017) at fireWith (https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js:2:28783) at j (https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js:2:30283) at k (https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js:2:30313) at c (https://osf.io/static/vendor/bower_components/raven-js/dist/raven.min.js:2:3899) undefined

However, looking at https://github.com/CenterForOpenScience/osf.io/commit/b7c494ed1148cc69597054a4e5189852e33b63e8 I realized that the problem seems to be that my repo is inside a nested folder (a "group" in GitLab's terminology). Indeed, I created a test repository that is at the top of the tree (i.e. gitlab.com/username/repo instead of gitlab.com/username/group/repo) and the sync with osf.io was successfull. Of course, GitLab allows for more than one levels of grouping and I do not expect you to support that feature, so let me know if a single group level is possible to parse without too much effort or not and I'll adjust the organization of my repos accordingly.

I still got some apparently innocuous errors in the console - probably nothing to worry about:

raven.js:695 GET https://files.osf.io/v1/resources/{GUID}/providers/gitlab/?branch=&meta=&_=1513283374168 400 (Bad Request) (anonymous) @ raven.js:695 D @ mithril.js:1086 r.request @ mithril.js:1142 i.request @ treebeard.js:43 (anonymous) @ treebeard.js:1050 i @ jquery.min.js:2 add @ jquery.min.js:2 toggleFolder @ treebeard.js:1046 onclick @ treebeard.js:2319 (anonymous) @ mithril.js:482

(EDIT: Redacted GUID)

sloria commented 6 years ago

@vkehayas Thanks for digging into that and for the thorough report. We'll evaluate what it will take to support repos within groups within the next week. Thanks for your patience!

sloria commented 6 years ago

@vkehayas OK, we released a fix that should allow repos within groups. Can you verify that you can connect your repo(s)?

vkehayas commented 6 years ago

Perfect! Repos up to at least two levels-deep in the tree work, as well as those at the top of the tree. Thanks a lot to all of you for your efforts and patience.

sloria commented 6 years ago

Great! Thanks for reporting the issue and for your patience while we fixed it.