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

Use debugPrint instead of str for fail arguments #18818

Closed
wants to merge 5 commits into from

Conversation

fmeum
Copy link
Collaborator

@fmeum fmeum commented Jun 29, 2023

This allows non-hermetic information (such as Starlark Locations) to be included in fail messages without allowing access to it from Starlark. It also aligns the content of fail output with that of print.

This change has very mild implications for backwards compatibility: it only affects the contents of fail messages, which aren't accessible from Starlark; debugPrint's default implementation is str and no built-in Starlark type overrides it; if a type overrides debugPrint, it would usually contain at least as detailed information as str; debugPrint is a "Bazelism" that isn't governed by the Starlark spec.

Work towards #17375

@fmeum fmeum changed the title Use debugPrint instead of str for fail parameters Use debugPrint instead of str for fail arguments Jun 29, 2023
@fmeum
Copy link
Collaborator Author

fmeum commented Jun 29, 2023

@brandjon Could you take a look at this?

It's a very lightweight alternative to #17889, aiming to resolve #17375.

Some change along these lines is necessary to make Bzlmod module extension error messages comprehensible - there is currently no way for them to point to the actual location that is the cause of a user error.

CC @Wyverald

@fmeum fmeum marked this pull request as ready for review June 29, 2023 23:17
@github-actions github-actions bot added the awaiting-review PR is awaiting review from an assigned reviewer label Jun 29, 2023
@sgowroji sgowroji added the team-ExternalDeps External dependency handling, remote repositiories, WORKSPACE file. label Jul 2, 2023
@fmeum
Copy link
Collaborator Author

fmeum commented Jul 5, 2023

@sgowroji While this would be applied to Bzlmod, the change affects the Starlark interpreter only - could you assign it to the respective team?

@sgowroji sgowroji added team-Starlark-Interpreter Issues involving the Starlark interpreter used by Bazel and removed team-ExternalDeps External dependency handling, remote repositiories, WORKSPACE file. labels Jul 5, 2023
@fmeum
Copy link
Collaborator Author

fmeum commented Aug 17, 2023

@brandjon Friendly ping, on the spectrum of the incompatible changes this should be tiny, but still very useful for Bzlmod's ability to generate error messages. It would be great to improve the situation in some way for Bazel 7. In case you are busy, could @tetromino review this?

@sgowroji sgowroji added the team-ExternalDeps External dependency handling, remote repositiories, WORKSPACE file. label Aug 17, 2023
Copy link
Contributor

@tetromino tetromino left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: can we reuse the same Printer?

@tetromino
Copy link
Contributor

I pushed a commit to reuse the printer.

@fmeum
Copy link
Collaborator Author

fmeum commented Aug 17, 2023

Thanks!

@github-actions github-actions bot removed the awaiting-review PR is awaiting review from an assigned reviewer label Aug 17, 2023
@fmeum fmeum deleted the fail-debug branch August 17, 2023 21:22
@fmeum
Copy link
Collaborator Author

fmeum commented Aug 17, 2023

@bazel-io flag

@bazel-io bazel-io added the potential release blocker Flagged by community members using "@bazel-io flag". Should be added to a release blocker milestone label Aug 17, 2023
@iancha1992
Copy link
Member

@bazel-io fork 6.4.0

@bazel-io bazel-io removed the potential release blocker Flagged by community members using "@bazel-io flag". Should be added to a release blocker milestone label Aug 18, 2023
bazel-io pushed a commit to bazel-io/bazel that referenced this pull request Aug 18, 2023
This allows non-hermetic information (such as Starlark `Location`s) to be included in `fail` messages without allowing access to it from Starlark. It also aligns the content of `fail` output with that of `print`.

This change has very mild implications for backwards compatibility: it only affects the contents of `fail` messages, which aren't accessible from Starlark; `debugPrint`'s default implementation is `str` and no built-in Starlark type overrides it; if a type overrides `debugPrint`, it would usually contain at least as detailed information as `str`; `debugPrint` is a "Bazelism" that isn't governed by the Starlark spec.

Work towards bazelbuild#17375

Closes bazelbuild#18818.

Co-authored-by: Alexandre Rostovtsev <arostovtsev@google.com>
PiperOrigin-RevId: 557916312
Change-Id: I8f202cd8530bcebb2d99f57745289b3992d03cac
iancha1992 pushed a commit that referenced this pull request Aug 18, 2023
This allows non-hermetic information (such as Starlark `Location`s) to
be included in `fail` messages without allowing access to it from
Starlark. It also aligns the content of `fail` output with that of
`print`.

This change has very mild implications for backwards compatibility: it
only affects the contents of `fail` messages, which aren't accessible
from Starlark; `debugPrint`'s default implementation is `str` and no
built-in Starlark type overrides it; if a type overrides `debugPrint`,
it would usually contain at least as detailed information as `str`;
`debugPrint` is a "Bazelism" that isn't governed by the Starlark spec.

Work towards #17375

Closes #18818.

Co-authored-by: Alexandre Rostovtsev <arostovtsev@google.com>
Commit
3abbf20

PiperOrigin-RevId: 557916312
Change-Id: I8f202cd8530bcebb2d99f57745289b3992d03cac

Co-authored-by: Fabian Meumertzheim <fabian@meumertzhe.im>
Co-authored-by: Alexandre Rostovtsev <arostovtsev@google.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
team-ExternalDeps External dependency handling, remote repositiories, WORKSPACE file. team-Starlark-Interpreter Issues involving the Starlark interpreter used by Bazel
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants