-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make @nix json structured build log parsing warn instead of fail #11921
base: master
Are you sure you want to change the base?
Conversation
src/libutil/logging.cc
Outdated
return true; | ||
} catch (nlohmann::json::exception &e) { | ||
warn( | ||
"warning: Unable to handle a JSON message from the builder: %s", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't like how this makes assumptions about where this function is being used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Spot on. That also fixes a technically incorrect message, although it was probably never seen.
Now:
if (handleJSONLogMessage(s, worker.act, worker.hook->activities, "the build hook", true))
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 on the idea, just don't like the anti-modular way the warning is done.
Interestingly, the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great now!
@roberth CI fails. |
Before this change, expressions like: with import <nixpkgs> {}; runCommand "foo" {} '' echo '@nix {}' >&$NIX_LOG_FD '' would result in Lix crashing, because accessing nonexistent fields of a JSON object throws an exception. Rather than handling each field individually, we just catch JSON exceptions wholesale. Since these log messages are an unusual circumstance, log a warning when this happens. Fixes #544. Change-Id: Idc2d8acf6e37046b3ec212f42e29269163dca893 (cherry picked from commit e55cd3beea710db727fd966f265a1b715b7285f3)
…warning correctly
8179d9d
to
2043cfa
Compare
This pull request has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/2024-11-20-nix-team-meeting-minutes-196/56688/1 |
Motivation
A build may log with
@nix something
without the intent to write Nix structured logs, resulting in an obscure error.This makes it easy to understand and continues the build.
Example:
Context
Cherry-picked from https://gerrit.lix.systems/c/lix/+/2057
Author @lheckemann
Priorities and Process
Add 👍 to pull requests you find important.
The Nix maintainer team uses a GitHub project board to schedule and track reviews.