thunlp / DebugBench

The repository for paper "DebugBench: "Evaluating Debugging Capability of Large Language Models".
Apache License 2.0
57 stars 6 forks source link

HTTP response body: {"error": "User is not authenticated"} #1

Closed shuaiwang2022 closed 9 months ago

shuaiwang2022 commented 10 months ago

image

Rachum-thu commented 9 months ago

This happens when the LeetCode server finds your cookie invalid.

Here are some common reasons:

Rachum-thu commented 9 months ago

This is how I obtained mine.

1. Go to leetcode.com

Notice that the leetcode OJ environment is not compatible with leetcode.cn

2. Log in to your account

Just to let you know, you must have your account verified by e-mail before you use it.

3. Activate the developer view of your browser

For example, if you are using Chrome, this will be View > Developer > Developer Tools.

4. Obtain the cookie

Go to Storage > Cookies > leetcode.com.

Copy the LEETCODE_SESSION entry. It should look like a long long string as eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJfYXV0aF91c2VyX2lkIjoiMTEyNzM3OTYiLCJfYXV0aF91c2VyX2JhY2tlbmQiOiJkamFuZ28uY29udHJpYi5hdXRoLmJhY2tlbmRzLk1vZG......

5. Do not manually log out or switch accounts.

It is OK if you close the web page. But manually logging out or switching accounts makes your cookie invalid.

If you really want to switch accounts, you may use the anonymous mode of your browser to get the cookie and close the page after that.

Rachum-thu commented 9 months ago

I closed the issue for now since I think my reply should resolve your problem. Welcome to re-open it if you have more issues.

YaseenMajdoob commented 6 months ago

I had the same error today, I've tried all the steps and still can't fix it

Rachum-thu commented 5 months ago

I had the same error today, I've tried all the steps and still can't fix it

I have tested the code today and it works well for me when the cookie is correct.

So from my perspectives, it is likely that you are getting an improper cookie.

Please leave your e-mail so that I can send you the cookie I use. You can try that out. If this cookie also works well for you, the code of this repository should be flawless.

Screenshot 2024-05-17 at 11 34 40
Rachum-thu commented 5 months ago

I had the same error today, I've tried all the steps and still can't fix it

If this problem continually bothers you, we can have a brief zoom meeting to solve it if you like :)

xuhaolei commented 4 months ago

I had the same error today, I've tried all the steps and still can't fix it

If this problem continually bothers you, we can have a brief zoom meeting to solve it if you like :)

I had the similar error, I follow your step and I think my cookie is right. Do you have time to test the code again? Maybe leetcode has changed something. image

Rachum-thu commented 4 months ago

@xuhaolei Hi, I have udpated leetcode_oj module. Now we should pass BOTH leetcode_session and csrf_token to the LeetCodeTester like this

leetcode_session = os.environ['LEETCODE_SESSION']
csrf_token = os.environ['CSRF_TOKEN']

class LeetCodeTester(object):

    def __init__(self, leetcode_session: str=None, csrf_token: str=None, cooldown: int=10):

        self.env = LeetCodeEnv(cooldown=cooldown, leetcode_session=leetcode_session, csrf_token=csrf_token)
        self.lang_dict = {
            "python": ProgrammingLanguage.PYTHON3,
            "python3": ProgrammingLanguage.PYTHON3,
            "java": ProgrammingLanguage.JAVA,
            "c": ProgrammingLanguage.C,
            "cpp": ProgrammingLanguage.CPP,
        }

    def test(self, code: str, task_id: str, language: str) -> tuple[bool, dict]:

        lang = self.lang_dict.get(language)
        sub = LeetCodeSubmission(code=code, lang=lang, question_slug=task_id)
        status, reward, done, submission_result = self.env.step(sub)
        return reward, submission_result

if __name__ == '__main__':

    tester = LeetCodeTester(leetcode_session=leetcode_session, csrf_token=csrf_token, cooldown=10)
    task_id = TEST_CASE['task_id']
    code0 = TEST_CASE['original_code']
    code1 = TEST_CASE['problematic_code']
    codes = [code0, code1]

    for code in codes:
        print(tester.test(code, task_id, "python"))

And this should work. Please inform me if you need more help.

Screenshot 2024-07-13 at 10 38 27
Rachum-thu commented 4 months ago

@xuhaolei Please e-mail me at runchutian@gmail.com if you need further assistance like zoom meeting or something.

TYrant-TY commented 3 weeks ago

@Rachum-thu I followed your steps, but I encountered a similar error. Do you have time to test the code again? image I