-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
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. |
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 |
Forgive me if this is off topic, but this might be of interest here: right now if I run
With |
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 e55cd3b)
…warning correctly
2043cfa
to
c783cd2
Compare
This has been fixed in nixpkgs in NixOS/nixpkgs#363672. |
This pull request has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/2024-12-09-nix-team-meeting-minutes-201/57280/1 |
Robert made these improvements on the PR that cherry-picked e55cd3b / https://gerrit.lix.systems/c/lix/+/2057 from Lix into CppNix: NixOS/nix#11921 Push log source description out of libutil and report build hook @nix warning correctly (cherry picked from commit 03d4bfd852dce9a050f984e887c887a43581796c) test: Move unusual-logging to run only in logging test case (cherry picked from commit 1421420e862434321c46511a3152016e443dd479) Remove redundant warning: prefix from structured build log warning (cherry picked from commit f3c722cab24f7a0de8c3573d25e91749f4f16234) Change-Id: I7da99046f2a41b3c58e62351119bc89bcc25a703
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.