leetcode-cli icon indicating copy to clipboard operation
leetcode-cli copied to clipboard

Anyhow(JSON error: expected value at line 1 column 1, please double check your session and csrf config.)

Open luciusluo opened this issue 8 months ago • 5 comments

So i have the latest csrf and lession configured to leetcode.toml, and I was running automated submission to leetcode using "leetcode exec $qid", for after about 30 mins, all my submission was getting the above error message.

Would be nice if i can be explained to why the above error keeps happening. My guess is the anti-scrape policy from leetcode.com?

luciusluo avatar Jun 03 '25 16:06 luciusluo

Thats happend to me but when my application has recursion.

Image

But just the plain works ..

Image

zodman avatar Jun 26 '25 23:06 zodman

Seems certain patterns of code trigger this error. Perhaps some parsing issue in Rust? @clearloop Could you help have a look on this?

summelon avatar Jul 31 '25 01:07 summelon

looks like we failed to decode sort types, could you please try running the command with debug flag? it's possible that it is caused by bad network as well

clearloop avatar Jul 31 '25 01:07 clearloop

Answer resulted in JSON error:

class Solution:
    def minPathSum(self, grid: List[List[int]]) -> int:
        m, n = len(grid), len(grid[0])

        @lru_cache(None)
        def best(r, c):
            if r == m - 1 and c == n - 1:
                return grid[r][c]
            down = best(r + 1, c) if r + 1 < m else float('inf')
            right = best(r, c + 1) if c + 1 < n else float('inf')
            return grid[r][c] + min(down, right)

        return best(0, 0)

Logging:


[2025-07-31T02:42:04Z INFO  leetcode_cli::plugins::leetcode] Sending code to judge...
[2025-07-31T02:42:04Z DEBUG reqwest::connect] starting new connection: https://leetcode.com/
[2025-07-31T02:42:04Z DEBUG reqwest::connect] proxy(myproxy) intercepts 'https://leetcode.com/'
Anyhow(JSON error: expected value at line 1 column 1, please double check your session and csrf config.)

Simple test without error:

class Solution:
    def minPathSum(self, grid: List[List[int]]) -> int:
        return 1

Logging:

[2025-07-31T02:43:55Z INFO  leetcode_cli::plugins::leetcode] Sending code to judge...
[2025-07-31T02:43:55Z DEBUG reqwest::connect] starting new connection: https://leetcode.com/
[2025-07-31T02:43:55Z DEBUG reqwest::connect] proxy(myproxy) intercepts 'https://leetcode.com/'
[2025-07-31T02:43:58Z DEBUG leetcode_cli::cache::models] VerifyResult {
        state: "SUCCESS",
        name: "Minimum Path Sum",
        data_input: "[[1,3,1],[1,5,1],[4,2,1]]\n[[1,2,3],[4,5,6]]",
        result_type: Test,
        pretty_lang: "Python3",
        correct_answer: false,
        code_answer: [
            "1",
            "1",
            "",
        ],
        code_output: [],
        expected_output: [],
        std_output: [],
        status: VerifyStatus {
            status_code: 10,
            status_msg: "Accepted",
            status_memory: "17.6 MB",
            status_runtime: "0 ms",
            runtime_error: "",
        },
        analyse: Analyse {
            total_correct: Some(
                Number(0),
            ),
            total_testcases: Some(
                Number(2),
            ),
            runtime_percentile: None,
            memory_percentile: None,
        },
        expected: Expected {
            expected_code_answer: [
                "7",
                "12",
                "",
            ],
        },
        error: CompileError {
            full_compile_error: "",
        },
        submit: Submit {
            question_id: "",
            last_testcase: "",
            compare_result: "00",
        },
    }

Wrong Answer   Runtime: 0 ms

Your input:    [[1,3,1],[1,5,1],[4,2,1]]↩ [[1,2,3],[4,5,6]]
Output:        1↩ 1↩
Expected:      7↩ 12↩

summelon avatar Jul 31 '25 02:07 summelon

thanks @summelon ! looks like we missed the debugging log of the root case, I'll replace the current error messages with more detailed context later today

clearloop avatar Jul 31 '25 05:07 clearloop