j178 / leetgo

Best LeetCode friend for geek. :snowboarder:
MIT License
534 stars 31 forks source link

[Bug] leetgo cache update without proxy would get empty json #299

Closed Luocy7 closed 5 months ago

Luocy7 commented 5 months ago

leetgo debug

Leetgo version info :

1.4.6
commit: 194bc48d1bc7a9d35a65b596665e7e62f3f50d02
built at: 2024-05-03T16:41:52Z
goos: darwin
goarch: arm64

Full configuration :

author: luocy
language: en
code:
  lang: python
  filename_template: '{{ .Id | padWithZero 4 }}{{ if .SlugIsMeaningful }}.{{ .Slug }}{{ end }}'
  separate_description_file: true
  modifiers:
    - name: removeUselessComments
  go:
    out_dir: go
    modifiers:
      - name: removeUselessComments
      - name: changeReceiverName
      - name: addNamedReturn
      - name: addMod
  python3:
    out_dir: python
    executable: python3
  cpp:
    out_dir: cpp
    cxx: g++
    cxxflags: -O2 -std=c++17
  rust:
    out_dir: rust
  java:
    out_dir: java
leetcode:
  site: https://leetcode.com
  credentials:
    from: browser
    browsers:
      - chrome
contest:
  out_dir: contest
  filename_template: '{{ .ContestShortSlug }}/{{ .Id }}{{ if .SlugIsMeaningful }}.{{ .Slug }}{{ end }}'
  open_in_browser: true
editor:
  use: custom
  command: pycharm
  args: '{{.CodeFile}}'

### Debug log

```shell
➜  DEBUG=1 leetgo cache update
2024/05/07 11:48:34 INFO cache updated path=/Users/luocy/.config/leetgo/cache/leetcode-questions.json

Description

when i turn off my proxy or set leetcode.com filter to direct, use leetgo cache update would get empty response without any another debug info.

however i can get correct response use incogito mode in chrome and safari when directly access https://leetcode.com/api/problems/all/

➜  cp leetcode-questions.json l-q.json
➜  ll
.rw-r--r-- luocy staff  34 B  Fri Apr 26 16:49:03 2024  deps.json
.rwxr-xr-x luocy staff 2.1 MB Tue May  7 11:47:57 2024  l-q.json
.rwxr-xr-x luocy staff 2.1 MB Mon May  6 10:34:09 2024  leetcode-questions.json
.rwxr-xr-x luocy staff 239 B  Mon Apr 29 10:16:37 2024  state.json
➜  DEBUG=1 leetgo cache update
2024/05/07 11:48:34 INFO cache updated path=/Users/luocy/.config/leetgo/cache/leetcode-questions.json
➜  ll
.rw-r--r-- luocy staff  34 B  Fri Apr 26 16:49:03 2024  deps.json
.rwxr-xr-x luocy staff 2.1 MB Tue May  7 11:47:57 2024  l-q.json
.rwxr-xr-x luocy staff   3 B  Tue May  7 11:48:34 2024  leetcode-questions.json
.rwxr-xr-x luocy staff 239 B  Mon Apr 29 10:16:37 2024  state.json
➜  cache tail leetcode-questions.json
[]

maybe is the sling ReceiveSuccess https://github.com/j178/leetgo/blob/9f645653ed8286b988b045509cb13fb3a984c55c/leetcode/client_us.go#L95 ignore the failed information which shows a 403 Forbidden resp

is there some bug in constructing the request or get response for all questions or maybe is my proxy`s problem :confused:

j178 commented 5 months ago

Thanks for the report, will take a look!