Skip to content
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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

roberth
Copy link
Member

@roberth roberth commented Nov 20, 2024

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:

echo '@nix ]['
bad JSON log message from builder: [json.exception.parse_error.101] parse error at line 1, column 1: syntax error while parsing value - unexpected ']'; expected '[', '{', or a literal
@nix ][

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.

roberth and others added 3 commits November 20, 2024 11:05
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)
@roberth roberth added bug derivation-build The process of building an individual derivation (see also sandbox label) labels Nov 20, 2024
@github-actions github-actions bot added the with-tests Issues related to testing. PRs with tests have some priority label Nov 20, 2024
@roberth roberth added backport 2.24-maintenance Automatically creates a PR against the branch backport 2.25-maintenance Automatically creates a PR against the branch labels Nov 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport 2.24-maintenance Automatically creates a PR against the branch backport 2.25-maintenance Automatically creates a PR against the branch bug derivation-build The process of building an individual derivation (see also sandbox label) with-tests Issues related to testing. PRs with tests have some priority
Projects
Status: To triage
Development

Successfully merging this pull request may close these issues.

2 participants