j178 / leetgo

Best LeetCode friend for geek. :snowboarder:
MIT License
535 stars 32 forks source link

[Bug] Can't submit in leetcode.com #292

Closed rgbygv closed 7 months ago

rgbygv commented 7 months ago

leetgo debug

Leetgo version info :

1.4.5
commit: 19a7eb1ba0bc2a376043a1afb5ad4660b046dafe
built at: 2024-04-04T02:09:03Z
goos: windows
goarch: amd64

Home dir : C:\Users\admin.config\leetgo Project root : C:\Users\admin\leetcode Working dir : C:\Users\admin\leetcode\rust Project config file : C:\Users\admin\leetcode\leetgo.yaml Project configuration:

author: Jones
language: en
code:
  lang: rust
  python3:
    blocks:
    - name: beforeMarker
      template: |

        from bisect import bisect_left, bisect_right
        from collections import Counter, defaultdict, deque
        from copy import deepcopy
        from functools import cache, cmp_to_key, lru_cache, reduce
        from heapq import heapify, heappop, heappush, heappushpop, heapreplace
        from itertools import accumulate, chain, count, pairwise, zip_longest
        from math import ceil, comb, floor, gcd, inf, isqrt, log2, perm, sqrt
        from operator import xor
        from pprint import pprint
        from string import ascii_lowercase
        from typing import List, Optional
  rust:
  blocks:
    - name: beforeCode
      template: |
        use std::cmp::Reverse;
        use std::collections::*;
        use std::mem::swap;
leetcode:
  site: https://leetcode.cn
  credentials:
    from: cookies
contest:
  open_in_browser: false
editor:
  use: custom
  command: "code"
  args: "{{.CodeFile}} {{.DescriptionFile}}"

Full configuration :

author: Jones
language: en
code:
  lang: rust
  filename_template: '{{ .Id | padWithZero 4 }}{{ if .SlugIsMeaningful }}.{{ .Slug }}{{ end }}'
  separate_description_file: true
  blocks:
    - name: beforeCode
      template: |
        use std::cmp::Reverse;
        use std::collections::*;
        use std::mem::swap;
  modifiers:
    - name: removeUselessComments
  go:
    out_dir: go
    modifiers:
      - name: removeUselessComments
      - name: changeReceiverName
      - name: addNamedReturn
      - name: addMod
  python3:
    out_dir: python
    blocks:
      - name: beforeMarker
        template: |2
          from bisect import bisect_left, bisect_right
          from collections import Counter, defaultdict, deque
          from copy import deepcopy
          from functools import cache, cmp_to_key, lru_cache, reduce
          from heapq import heapify, heappop, heappush, heappushpop, heapreplace
          from itertools import accumulate, chain, count, pairwise, zip_longest
          from math import ceil, comb, floor, gcd, inf, isqrt, log2, perm, sqrt
          from operator import xor
          from pprint import pprint
          from string import ascii_lowercase
          from typing import List, Optional
    executable: python.exe
  cpp:
    out_dir: cpp
    cxx: g++
    cxxflags: -O2 -std=c++17
  rust:
    out_dir: rust
  java:
    out_dir: java
leetcode:
  site: https://leetcode.cn
  credentials:
    from: cookies
    browsers: []
contest:
  out_dir: contest
  filename_template: '{{ .ContestShortSlug }}/{{ .Id }}{{ if .SlugIsMeaningful }}.{{ .Slug }}{{ end }}'
  open_in_browser: false
editor:
  use: custom
  command: code
  args: '{{.CodeFile}} {{.DescriptionFile}}'

Debug log

No response

Description

lc test last -Ls --site us
● running test locally question=make-the-string-great
● building file=src/1544.make-the-string-great/solution.rs
● Case 1:    Passed
● Case 2:    Passed
● Case 3:    Passed
● submitting solution user=@leetcode.com
⣻ Submitting solution...● retry url=https://leetcode.com/problems/make-the-string-great/submit/ attempt=0 error="[403 Forbidden] <empty>"
⣾ Submitting solution...● retry url=https://leetcode.com/problems/make-the-string-great/submit/ attempt=1 error="[403 Forbidden] <empty>"
⣾ Submitting solution...● retry url=https://leetcode.com/problems/make-the-string-great/submit/ attempt=2 error="[403 Forbidden] <empty>"
× failed to submit solution err="failed to submit solution: [403 Forbidden] <empty>"

Something strange here, ● submitting solution user=@leetcode.com, seems like it doesn't recognize my username I tried changing my cookies but the problem persists.

j178 commented 7 months ago

Since you're using cookies, have you configured all three env vars – LEETCODE_SESSION, LEETCODE_CSRFTOKEN, and LEETCODE_CFCLEARANCE – to access leetcode.com ?

rgbygv commented 7 months ago

Yes of course. I created a function like this in pwsh to differentiate between us and cn.

function us{
    $env:LEETCODE_SESSION="eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJfYXV0aF91c2VyX2lkIjoiNDMzOTYzOSIsIl9hdXRoX3VzZXJfYmFja2VuZCI6ImFsbGF1dGguYWNjb3VudC5hdXRoX2JhY2tlbmRzLkF1dGhlbnRpY2F0aW9uQmFja2VuZCIsIl9hdXRoX3VzZXJfaGFzaCI6ImY4MjBmNmM..."
    $env:LEETCODE_CSRFTOKEN="w31CEXc7nkdUDuSPdHLnhdKoYV7Rgia..."
    $env:LEETCODE_CFCLEARANCE="ntOKjS2Rz9PsrvzQoDujserauLAU3MYGlyqhjpcDyjc-1712317600-1.0.1.1..."
}

I tried logging back in (of cource .com) and replacing the three envs with new ones but still can't submit. If you can't reproduce the issue, maybe there's something wrong with my browser. I will test it a few times and give feedback.

j178 commented 7 months ago

Sorry, I can't reproduce on my side, either by setting cookies env var or by fetching cookies from browser automatically. Could you try using feching cookies from browsers automatically?

rgbygv commented 7 months ago

Thanks, I download a new browser then try using automatic get cookie from browser and now it works. Maybe there's something wrong with my origin browser.