flake update json parse coredump when gitlab api coudn't be fetched #642

Closed
opened 2025-01-23 12:51:18 +00:00 by leona-ya · 4 comments
Member

Describe the bug

I tried to run nix flake update in d15f0b6265 with a bad network connection. lix fails to connect to the GitLab (one of the inputs) and then crashes as the GitLab API "result" is empty.

Steps To Reproduce

  • create a flake with a GitLab input (probably others are also affected)
  • provoke a timeout or dns resolution error
  • run nix flake update

Expected behavior

It shouldn't crash ;)

nix --version output

nix (Lix, like Nix) 2.92.0
System type: x86_64-linux
Additional system types: aarch64-linux, i686-linux
Features: gc, signed-caches
System configuration file: /etc/nix/nix.conf
User configuration files: /home/leona/.config/nix/nix.conf:/etc/xdg/nix/nix.conf:/home/leona/.nix-profile/etc/xdg/nix/nix.conf:/nix/profile/etc/xdg/nix/nix.conf:/home/leona/.local/state/nix/profile/etc/xdg/nix/nix.conf:/etc/profiles/per-user/leona/etc/xdg/nix/nix.conf:/nix/var/nix/profiles/default/etc/xdg/nix/nix.conf:/run/current-system/sw/etc/xdg/nix/nix.conf
Store directory: /nix/store
State directory: /nix/var/nix
Data directory: /nix/store/ipybd6h2yy2igfprg8q0czipxl8d11d4-lix-2.92.0/share

Additional context

λ nix flake update
warning: Git tree '/home/leona/dev/nixfiles' is dirty
warning: error: unable to download 'https://cyberchaos.dev/api/v4/projects/cyberchaoscreatures%2Fnixlib/repository/commits?ref_name=main': Could not connect to server (7) Failed to connect to cyberchaos.dev port 443 after 11386 ms: Could not connect to server; retrying in 347 ms
Lix crashed. This is a bug. We would appreciate if you report it along with what caused it at https://git.lix.systems/lix-project/lix/issues with the following information included:

Exception: nlohmann::json_abi_v3_11_3::detail::parse_error: [json.exception.parse_error.101] parse error at line 1, column 1: attempting to parse an empty input; check that your input string or stream contains the expected JSON
Stack trace:
 0# nix::printStackTrace() in /nix/store/ipybd6h2yy2igfprg8q0czipxl8d11d4-lix-2.92.0/lib/liblixutil.so
 1# 0x00007F5FB4AE0B26 in /nix/store/ipybd6h2yy2igfprg8q0czipxl8d11d4-lix-2.92.0/lib/liblixmain.so
 2# 0x00007F5FB3ABF20A in /nix/store/bpq1s72cw9qb2fs8mnmlw6hn2c7iy0ss-gcc-14-20241116-lib/lib/libstdc++.so.6
 3# std::unexpected() in /nix/store/bpq1s72cw9qb2fs8mnmlw6hn2c7iy0ss-gcc-14-20241116-lib/lib/libstdc++.so.6
 4# nix::handleExceptions(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::function<void ()>) in /nix/store/ipybd6h2yy2igfprg8q0czipxl8d11d4-lix-2.92.0/lib/liblixmain.so
 5# 0x00005654E598B89B in nix
 6# 0x00007F5FB362A1FC in /nix/store/65h17wjrrlsj2rj540igylrx7fqcd6vq-glibc-2.40-36/lib/libc.so.6
 7# __libc_start_main in /nix/store/65h17wjrrlsj2rj540igylrx7fqcd6vq-glibc-2.40-36/lib/libc.so.6
 8# 0x00005654E58DC875 in nix

[1]    103765 IOT instruction (core dumped)  nix flake update

coredump: https://cloud.leona.is/s/2sSbDbGMoGfYKMM

## Describe the bug I tried to run `nix flake update` in https://forkspace.net/leona/nixfiles/-/tree/d15f0b6265771dcbf4ec92ddb362396fb4efacf3 with a bad network connection. lix fails to connect to the GitLab (one of the inputs) and then crashes as the GitLab API "result" is empty. ## Steps To Reproduce - create a flake with a GitLab input (probably others are also affected) - provoke a timeout or dns resolution error - run `nix flake update` ## Expected behavior It shouldn't crash ;) ## `nix --version` output ``` nix (Lix, like Nix) 2.92.0 System type: x86_64-linux Additional system types: aarch64-linux, i686-linux Features: gc, signed-caches System configuration file: /etc/nix/nix.conf User configuration files: /home/leona/.config/nix/nix.conf:/etc/xdg/nix/nix.conf:/home/leona/.nix-profile/etc/xdg/nix/nix.conf:/nix/profile/etc/xdg/nix/nix.conf:/home/leona/.local/state/nix/profile/etc/xdg/nix/nix.conf:/etc/profiles/per-user/leona/etc/xdg/nix/nix.conf:/nix/var/nix/profiles/default/etc/xdg/nix/nix.conf:/run/current-system/sw/etc/xdg/nix/nix.conf Store directory: /nix/store State directory: /nix/var/nix Data directory: /nix/store/ipybd6h2yy2igfprg8q0czipxl8d11d4-lix-2.92.0/share ``` ## Additional context ``` λ nix flake update warning: Git tree '/home/leona/dev/nixfiles' is dirty warning: error: unable to download 'https://cyberchaos.dev/api/v4/projects/cyberchaoscreatures%2Fnixlib/repository/commits?ref_name=main': Could not connect to server (7) Failed to connect to cyberchaos.dev port 443 after 11386 ms: Could not connect to server; retrying in 347 ms Lix crashed. This is a bug. We would appreciate if you report it along with what caused it at https://git.lix.systems/lix-project/lix/issues with the following information included: Exception: nlohmann::json_abi_v3_11_3::detail::parse_error: [json.exception.parse_error.101] parse error at line 1, column 1: attempting to parse an empty input; check that your input string or stream contains the expected JSON Stack trace: 0# nix::printStackTrace() in /nix/store/ipybd6h2yy2igfprg8q0czipxl8d11d4-lix-2.92.0/lib/liblixutil.so 1# 0x00007F5FB4AE0B26 in /nix/store/ipybd6h2yy2igfprg8q0czipxl8d11d4-lix-2.92.0/lib/liblixmain.so 2# 0x00007F5FB3ABF20A in /nix/store/bpq1s72cw9qb2fs8mnmlw6hn2c7iy0ss-gcc-14-20241116-lib/lib/libstdc++.so.6 3# std::unexpected() in /nix/store/bpq1s72cw9qb2fs8mnmlw6hn2c7iy0ss-gcc-14-20241116-lib/lib/libstdc++.so.6 4# nix::handleExceptions(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::function<void ()>) in /nix/store/ipybd6h2yy2igfprg8q0czipxl8d11d4-lix-2.92.0/lib/liblixmain.so 5# 0x00005654E598B89B in nix 6# 0x00007F5FB362A1FC in /nix/store/65h17wjrrlsj2rj540igylrx7fqcd6vq-glibc-2.40-36/lib/libc.so.6 7# __libc_start_main in /nix/store/65h17wjrrlsj2rj540igylrx7fqcd6vq-glibc-2.40-36/lib/libc.so.6 8# 0x00005654E58DC875 in nix [1] 103765 IOT instruction (core dumped) nix flake update ``` coredump: https://cloud.leona.is/s/2sSbDbGMoGfYKMM
Owner

@lheckemann i think you know more about the gitlab code or who to ping

@lheckemann i think you know more about the gitlab code or who to ping
Member

This doesn't happen with

{ inputs.test = {type = "gitlab"; host = "gitlab.invalid"; owner = "foo"; repo = "bar";}; outputs = _: {};}

(which does result in a DNS resolution failure as suggested); is there any reliable way to reproduce this?

This doesn't happen with ```nix { inputs.test = {type = "gitlab"; host = "gitlab.invalid"; owner = "foo"; repo = "bar";}; outputs = _: {};} ``` (which does result in a DNS resolution failure as suggested); is there any reliable way to reproduce this?
Owner

maybe you need a name that resolves but doesn't reply? idk. maybe try localhost, assuming you don't have a web server running? or it might have to actually fully time out, so you'd need a black hole; could make one of those with iptables i guess.

maybe you need a name that resolves but doesn't reply? idk. maybe try localhost, assuming you don't have a web server running? or it might have to actually fully time out, so you'd need a black hole; could make one of those with iptables i guess.
Member

This issue was mentioned on Gerrit on the following CLs:

  • commit message in cl/2907 ("treewide: handle JSON parse errors")
<!-- GERRIT_LINKBOT: {"cls": [{"backlink": "https://gerrit.lix.systems/c/lix/+/2907", "number": 2907, "kind": "commit message"}], "cl_meta": {"2907": {"change_title": "treewide: handle JSON parse errors"}}} --> This issue was mentioned on Gerrit on the following CLs: * commit message in [cl/2907](https://gerrit.lix.systems/c/lix/+/2907) ("treewide: handle JSON parse errors")
Sign in to join this conversation.
No milestone
No project
No assignees
4 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: lix-project/lix#642
No description provided.