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

Error: Project details could not be queried. #61

Open
LuckyJinging opened this issue Nov 29, 2022 · 8 comments · May be fixed by #66
Open

Error: Project details could not be queried. #61

LuckyJinging opened this issue Nov 29, 2022 · 8 comments · May be fixed by #66

Comments

@LuckyJinging
Copy link

I can obtain the project list with ols list, but I got an error when I do ols -l or ols -r to sync files.

Project queried successfully.
✅ Querying project
💥 Querying project details
Error: Project details could not be queried.

@saran-ravi
Copy link

Same problem here, I could not download the project files

@elonhub
Copy link

elonhub commented Dec 1, 2022

Same here, more info:

> ols -v -n 'PROJECT' -r
Project queried successfully.
✅  Querying project
⠋ Querying project detailsTraceback (most recent call last):
  File "/home/user/.local/lib/python3.10/site-packages/olsync/olsync.py", line 348, in execute_action
    success = action()
  File "/home/user/.local/lib/python3.10/site-packages/olsync/olsync.py", line 73, in <lambda>
    lambda: overleaf_client.get_project_infos(project["id"]),
  File "/home/user/.local/lib/python3.10/site-packages/olsync/olclient.py", line 167, in get_project_infos
    self._cookie["GCLB"],
KeyError: 'GCLB'

💥  Querying project details
Error: Project details could not be queried.

That line reads:

    164         # Convert cookie from CookieJar to string
    165         cookie = "GCLB={}; overleaf_session2={}" \
    166             .format(
    167             self._cookie["GCLB"],
    168             self._cookie["overleaf_session2"]
    169         )

That self._cookie would probably need to come from OverleafClient.login() which states, that its DEPRECATED.
I hope that helps a bit.

@liamoconnor9
Copy link

Same issue, itstorque's commit remedied this after generating a new login cookie

@CeciliaCoelho
Copy link

After getting the same error itstorque's commit fixed it but today a different error message appeared. Using linux

 >> ols login 
Persisted Overleaf cookie already exist. Do you want to override it? [y/N]: y
⠸ Loginjs: Uncaught TypeError: Cannot read properties of undefined (reading 'href')
js: Uncaught TypeError: Cannot read properties of undefined (reading 'content')
Login successful. Cookie persisted as `.olauth`. You may now sync your project.
✅  Login

>> ols -r 
💥  Querying project
Error: Project could not be queried.

@svennniiii svennniiii linked a pull request Mar 10, 2023 that will close this issue
@svennniiii
Copy link

svennniiii commented Mar 10, 2023

Hi @CeciliaCoelho, @itstorque's commit also stopped working for me. It seems Overleaf has made some changes on the website. These modifications (see #66) worked for me.

@itstorque
Copy link

itstorque commented Mar 11, 2023

Took a look at the rendered HTML for the landing page, they removed the classes for the links in the table. I think replacing the line

JAVASCRIPT_EXTRACT_PROJECT_URL = "document.getElementsByClassName('project-list-table-name-link')[0].href"

with this

JAVASCRIPT_EXTRACT_PROJECT_URL = "document.getElementsByTagName('tbody')[0].children[0].getElementsByTagName('a')[0].href"

should work. Its very jank, if they introduce another table in the HTML before the project list, it will break.

Another possible implementation that I prefer would be replacing that line with

JAVASCRIPT_EXTRACT_PROJECT_URL = "q=0;for (const c of document.getElementsByTagName('a')) { if(c.href.indexOf('/project/') > 0) { q=c.href; break; } }; q"

The thinking here is that support for URLs is more concrete (backcompatibility) and therefore changes to the html page wouldn't break the ability to find a link to a project to load the GCLB cookie.

Note: I didn't test these, but I am confident that they should work (lmk otherwise)

@svennniiii
Copy link

I think this alone doesn't do the trick. Additionally, I had to do two changes in class OverleafClient(object) in the methods that deal with querying the project (def all_projects(self) and def get_project(self)). (see #66)

I don't know how the old landing page looked like, but it may be due to the same design changes.

@D-VR
Copy link

D-VR commented Aug 17, 2023

I replaced the files in the pip module with the fixes from the linked repository in #66, but I am getting the following issue using ols download -v (with a fresh login token)

Traceback (most recent call last):
  File "/home/user/.local/lib/python3.11/site-packages/olsync/olsync.py", line 354, in execute_action
    success = action()
              ^^^^^^^^
  File "/home/user/.local/lib/python3.11/site-packages/olsync/olsync.py", line 179, in download_project_pdf
    project = execute_action(
              ^^^^^^^^^^^^^^^
  File "/home/user/.local/lib/python3.11/site-packages/olsync/olsync.py", line 365, in execute_action
    raise click.ClickException(fail_message)
click.exceptions.ClickException: Project could not be queried.

💥  Downloading project's PDF
Error: Downloading project's PDF failed. Please try again.

EDIT:

User error, I forgot to select the project I want to sync / download.

correct command to do is: ols download -n my_project the fix works perfectly!

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

Successfully merging a pull request may close this issue.

8 participants