bazelbuild / bazelbuild/bazel

Feature: Ability to Emit Warnings in Rules

Open
#19,529 1 comment 4 reactions 0 assignees View on GitHub
team-Starlark-Interpreter type: feature request untriaged
Dominant language
Java
Stars
25.8k
Forks
4.6k
Avg merge
2d 18h
Merged PRs (30d)
75

Description

### Description of the feature request:

This may be a feature request for Starlark rather than Bazel, but I'd like the ability to emit warnings (and potentially other message types, similar to a proper logging system) for custom Bazel rules.

Similar to the `print(msg)` function in Starlark I'd like to be able to see something like a `warning(msg)` function that would emit a warning message akin to `WARNING: `.

### Which category does this issue belong to?

Core, Starlark Interpreter

### What underlying problem are you trying to solve with this feature?

I have a use case where upon improving the implementation of a Bazel rule I've removed one of the input fields (the field is no longer necessary and it determined automatically). I'd like to emit a warning in the updated rule to inform the user that the field is deprecated and to be removed to allow them time to update their target definitions before using something like `fatal()` in the future to force an error if the field is specified.

### Which operating system are you running Bazel on?

Ubuntu

### What is the output of `bazel info release`?

release 4.2.2-2.7

### If `bazel info release` returns `development version` or `(@non-git)`, tell us how you built Bazel.

_No response_

### What's the output of `git remote get-url origin; git rev-parse master; git rev-parse HEAD` ?

_No response_

### Have you found anything relevant by searching the web?

No, only relevant results I've found are for the `print()` and `fatal()` functions, neither or which suit my use case.

### Any other information, logs, or outputs that you want to share?

_No response_

Contributor guide

Open the contributing guide

Research direction

The issue identifies Starlark print() and fatal() as the relevant entry points; begin by tracing how those functions report messages in the Starlark interpreter. Define the warning behavior and message routing, then verify that custom Bazel rules can emit the requested warning without making it fatal.

Written by the indexing model from the issue text.

Assessment

Domain
build-system
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.