Skip to content

Failed to load locked problem #91

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

Closed
yuzhoul1991 opened this issue Mar 2, 2018 · 20 comments
Closed

Failed to load locked problem #91

yuzhoul1991 opened this issue Mar 2, 2018 · 20 comments

Comments

@yuzhoul1991
Copy link

Problem Summary

It is no longer able to show and download the locked questions all of a sudden. I am still premium member.

How to reproduce

$ leetcode show 298 -g -vv ⬡ 9.4.0
[TRACE] initializing all plugins
[TRACE] found plugin: cache=default
[TRACE] inited plugin: cache
[TRACE] found plugin: company=2017.12.18
[TRACE] inited plugin: company
[TRACE] found plugin: cpp.run=2017.07.29
[TRACE] inited plugin: cpp.run
[TRACE] found plugin: github=2018.01.06
[TRACE] inited plugin: github
[TRACE] found plugin: leetcode=default
[TRACE] inited plugin: leetcode
[TRACE] found plugin: retry=default
[TRACE] inited plugin: retry
[TRACE] missing plugins: 0
[DEBUG] cache hit: problems.json
[DEBUG] running leetcode.getProblem
[ERROR] failed to load locked problem! [0]

Environment

leetcode version returns 2.5.1

  • leetcode-cli version:
  • OS version:

redhat, not sure what version, it was working just a few days ago i think

  • Node version:

v9.4.0

  • Npm version:
    5.6.0
@skygragon
Copy link
Owner

@yuzhoul1991 Have you tried manually re-login?

@yuzhoul1991
Copy link
Author

yuzhoul1991 commented Mar 2, 2018 via email

@skygragon
Copy link
Owner

There might be a bug if we have old problems.json cached, please try to clear the cache? I don't have premium account thus can't test it all.

leetcode cache -d problems

@skygragon skygragon added the bug label Mar 2, 2018
@15cm
Copy link

15cm commented Mar 6, 2018

Same problem here. Even after clear the cache by leetcode cache -d.

@skygragon
Copy link
Owner

skygragon commented Mar 6, 2018

Sorry I can't debug this but I could give a hint that you might debug by yourself.

"failed to load locked problem" occurs in lib/plugins/leetcode.js:123, which implies "user.paid" is unexpectedly false.

123   if (problem.locked && !user.paid) return cb('failed to load locked problem!');

user.paid is assigned in lib/plugins/leetcode.js:95, which is extracted from the returned json of "https://leetcode.com/api/problems/$category/". For paid user, this "is_paid" field in json should be true (expected but not tested recently).

 76 plugin.getCategoryProblems = function(category, cb) {
 77   log.debug('running leetcode.getCategoryProblems: ' + category);
 78   const opts = makeOpts(config.sys.urls.problems.replace('$category', category));
 79
 80   spin.text = 'Downloading category ' + category;
 81   request(opts, function(e, resp, body) {
 82     e = checkError(e, resp, 200);
 83     if (e) return cb(e);
 84
 85     const json = JSON.parse(body);
 86
 87     // leetcode permits anonymous access to the problem list
 88     // while we require login first to make a better experience.
 89     if (json.user_name.length === 0) {
 90       log.debug('no user info in list response, maybe session expired...');
 91       return cb(session.errors.EXPIRED);
 92     }
 93
 94     const user = session.getUser();
 95     user.paid = json.is_paid;

I guess the latest json response has been changed recently that doesn't contain "is_paid" field anymore, which means we need seek other ways to detect paid user.

@15cm
Copy link

15cm commented Mar 6, 2018

Maybe we can try to fetch the subscription state from leetcode.com/subscription/.

I currently delete lib/plugins/leetcode.js:123 as a temporary fix for myself.

@yunweiyuan
Copy link

Facing the same issue. But still cannot accessing the locked problem after deleting lib/plugins/leetcode.js:123, or manually setting user.paid to true.

@pengyu-hou
Copy link

I am running into the same issue as well. Tried upgrading to the latest version and deleting the cache. Nothing worked yet.

@yyang325
Copy link

Facing same error here.

@hankok
Copy link

hankok commented May 9, 2018

Same

@skygragon
Copy link
Owner

@ALL feel free to try #96 to temporarily bypass the premium user check in leetcode-cli. I can't test it myself because I don't have a premium account...

@sfdye
Copy link

sfdye commented Oct 3, 2018

Facing the same issue. @skygragon Would you mind cutting a new release to include the master fix fc7a09b?

@tenbabagu
Copy link

any update?

@rockyzhang24
Copy link

any updates? Thx

@skygragon
Copy link
Owner

@sfdye does fc7a09b fix the issue? if so, I would kickoff a new release for it.

@sfdye
Copy link

sfdye commented Oct 28, 2018

Yes it does. Please do.

@skygragon
Copy link
Owner

2.5.3 released, enjoy it

@rockyzhang24
Copy link

@skygragon Thanks. Btw, I installed it using 'npm install -g skygragon/leetcode-cli', i.e., the DEV version from GitHub which is now under 2.5.2. How to update it to 2.5.3? I just tried 'npm update -g skygragon/leetcode-cli' but nothing happened.

@skygragon
Copy link
Owner

@yanzhang0219 the last resort is to uninstall fist then install again :)

@rockyzhang24
Copy link

@skygragon Yep, that's what I did. Thanks.

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

No branches or pull requests

10 participants