Make @nix json structured build log parsing warn instead of fail#11921
Make @nix json structured build log parsing warn instead of fail#11921Ericson2314 merged 7 commits intomasterfrom
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.
Don't like how this makes assumptions about where this function is being used.
There was a problem hiding this comment.
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))
Ericson2314
left a comment
There was a problem hiding this comment.
+1 on the idea, just don't like the anti-modular way the warning is done.
|
Interestingly, the |
|
@roberth CI fails. |
8179d9d to
2043cfa
Compare
|
This pull request has been mentioned on NixOS Discourse. There might be relevant details there: |
|
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: |
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 somethingwithout 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.