nix icon indicating copy to clipboard operation
nix copied to clipboard

flake update: json.exception.type_error.302

Open pleshevskiy opened this issue 3 years ago • 11 comments

Describe the bug

I cannot use nix flake update command on my current configuration

Steps To Reproduce

➜ nix flake update                                         
error: [json.exception.type_error.302] type must be string, but is null

Expected behavior

➜ nix flake update
| * Updated 'nixpkgs': 'github:NixOS/nixpkgs/3d2d8f281a27d466fa54b469b5993f7dde198375' -> 'github:NixOS/nixpkgs/a3a3dda3bacf61e8a39258a0ed9c924eeca8e293'

nix-env --version output

nix-env (Nix) 2.10.3

Additional context

OS: NixOS 22.11.20220828.a63021a (Raccoon) x86_64

pleshevskiy avatar Sep 14 '22 07:09 pleshevskiy

That seems to be due to an issue with the gitlab fetcher: gitlab:pleshevskiy/dedsec-grub-theme/nix-flake wants to fetch the nix-flake branch of pleshevskiy/dedsec-grub-theme, but it doesn't exist and the gitlab API returns an empty json array, which confuses Nix.

thufschmitt avatar Sep 14 '22 09:09 thufschmitt

Thank you! It may have been deleted in the merge.

P.S. The error could have been a bit better. For example "trying to update dedsec-grub-theme flake, but there was an error".

pleshevskiy avatar Sep 14 '22 09:09 pleshevskiy

P.S. The error could have been a bit better. For example "trying to update dedsec-grub-theme flake, but there was an error".

Of totally, there's definitely a Nix issue here :)

thufschmitt avatar Sep 14 '22 09:09 thufschmitt

Pfff, I've hit this one and it's quite baffling.

It happened because I had outdated flake.lock from a different project, but it took me a while to figure out it's Nix complaining about the lock file, ideally there would be some context why JSON exception occurred.

domenkozar avatar Nov 08 '22 20:11 domenkozar

@bburdette this one is a real pain.

domenkozar avatar Dec 20 '22 11:12 domenkozar

Mentioned on twitter: https://twitter.com/kerckhove_ts/status/1605154924542705668?s=20&t=sp6J0cte0iYt4UvCY9Bbtw

Note that the problem is not the error per-se, but the lag of diagnostic info.

NorfairKing avatar Dec 20 '22 11:12 NorfairKing

Still relevant

Synthetica9 avatar Aug 08 '24 08:08 Synthetica9

Mentioned on twitter: https://twitter.com/kerckhove_ts/status/1605154924542705668?s=20&t=sp6J0cte0iYt4UvCY9Bbtw

the link is dead, was there anything useful?

Just happened upon similar problem with a new machine, while there are no issues using the same repository on the old ones. nix-build ends up with error: [json.exception.type_error.302] type must be array, but is string and debugging it is a bit hard

sukhmel avatar May 28 '25 09:05 sukhmel

Mentioned on twitter: twitter.com/kerckhove_ts/status/1605154924542705668?s=20&t=sp6J0cte0iYt4UvCY9Bbtw

the link is dead, was there anything useful?

Just happened upon similar problem with a new machine, while there are no issues using the same repository on the old ones. nix-build ends up with error: [json.exception.type_error.302] type must be array, but is string and debugging it is a bit hard

What version did you notice this on? That sounds a lot like https://github.com/NixOS/nix/issues/13254, which https://github.com/NixOS/nix/pull/13256 fixed and will be in the next release (shameless plug, this is also fixed in the currently-released Determinate Nix 3.6.1).

cole-h avatar May 28 '25 14:05 cole-h

@cole-h I just got back with an update, this is indeed on 2.29.0 and likely related, but in my case this was because dockerTools didn't generate a config, substitutor tried to find the config derivation because the file was missing, and likely this lead to the error itself.

I am yet to reproduce no config on another machine to file an issue, as I wasn't able to find one.

So the reason in my case was different, but a diagnostic message with context would've helped a lot. I've managed to debug it with increased verbosity -vvv but it required some searching around for what derivation is missing when it shouldn't.

sukhmel avatar May 29 '25 10:05 sukhmel

@cole-h I've reproduced the issue with images we use in production, nix 2.29 fails, where nix 2.28 works fine. But I have trouble creating a reproducible docker image because of a different error, so I guess I will leave it at that for now.

sukhmel avatar Jun 02 '25 13:06 sukhmel

my issue with dockerTools seems to have been fixed in 2.29.1, as this no longer reproduces

sukhmel avatar Aug 26 '25 14:08 sukhmel