nixos/systemd-boot: refactor json.load() logic for better error message#421916
Merged
ElvishJerricco merged 1 commit intoNixOS:masterfrom Jul 28, 2025
Merged
nixos/systemd-boot: refactor json.load() logic for better error message#421916ElvishJerricco merged 1 commit intoNixOS:masterfrom
ElvishJerricco merged 1 commit intoNixOS:masterfrom
Conversation
Contributor
ElvishJerricco
left a comment
There was a problem hiding this comment.
We probably still need to throw the exception, not just print it. I don't know python well enough; what's the appropriate way to add context to an exception but still throw it? @JulienMalka?
Member
|
I think for a user‐facing error a print is more appropriate. Tools shouldn’t throw exceptions to the user unless something went wrong internally. But it should |
Member
|
I agree with @emilazy |
Member
Author
c852bd4 to
75f09d7
Compare
Member
Author
|
@JulienMalka @emilazy @ElvishJerricco , anything more that needs to happen? |
nixos/modules/system/boot/loader/systemd-boot/systemd-boot-builder.py
Outdated
Show resolved
Hide resolved
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Last weekend I ran into a few bugs while trying to rebuild in emergency mode after managing to corrupt my filesystem. The problem was a corrupted

boot.jsonin one of the system profiles stored in/nix/var/nix/profiles/system-x-link/. This causednixos-rebuild bootto fail.The solution was to remove this corrupt
boot.jsonand rebuild boot from there. In a system with many generations it can be challenging to find the corrupted file and remove it. To fix this I've added a try except to throw an error if parsing the json fails. This allows the user to find the guilty file easily. Below is the new error that is thrown. (outdated)@ElvishJerricco @emilazy @JulienMalka
Things done
nix.conf? (See Nix manual)sandbox = relaxedsandbox = truenix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/)Add a 👍 reaction to pull requests you find important.