Leaderboard download fails if leaderboard only contains one page

kaggle competitions leaderboard --download lux-ai-2021                                                                          ✔  kaggle 
Traceback (most recent call last):
  File "/usr/local/Caskroom/miniforge/base/envs/kaggle/bin/kaggle", line 11, in <module>
    sys.exit(main())
  File "/usr/local/Caskroom/miniforge/base/envs/kaggle/lib/python3.9/site-packages/kaggle/cli.py", line 67, in main
    out = args.func(**command_args)
  File "/usr/local/Caskroom/miniforge/base/envs/kaggle/lib/python3.9/site-packages/kaggle/api/kaggle_api_extended.py", line 831, in competition_leaderboard_cli
    self.competition_leaderboard_download(competition, path, quiet)
  File "/usr/local/Caskroom/miniforge/base/envs/kaggle/lib/python3.9/site-packages/kaggle/api/kaggle_api_extended.py", line 784, in competition_leaderboard_download
    self.download_file(response, outfile, quiet)
  File "/usr/local/Caskroom/miniforge/base/envs/kaggle/lib/python3.9/site-packages/kaggle/api/kaggle_api_extended.py", line 1584, in download_file
    size = int(response.headers['Content-Length'])
  File "/usr/local/Caskroom/miniforge/base/envs/kaggle/lib/python3.9/site-packages/urllib3/_collections.py", line 152, in __getitem__
    val = self._container[key.lower()]
KeyError: 'content-length'

The content-length property is not set if the leaderboard is returned in one response (instead of being paginated).

Read more here: Source link