bazel-contrib / bazel-contrib/buildtools

[buildozer] Incorrect lowercasing of first occurrence of letter 'E' in identifier expressions containing a dot when using :expr

Open
#1,497 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
1.2k
Forks
471
Avg merge
2d 22h
Merged PRs (30d)
13

Description

When using Buildozer to add an expression (using the :expr type specifier) that contains an uppercase letter 'E' and a dot '.', Buildozer incorrectly lowercases the first occurrence of 'E' to 'e'. Since Starlark is case-sensitive, this breaks identifier resolution.

**Reproduction steps**:

Copy these bash commands to fully reproduce the issue:
```
mkdir buildozer-bug-poc && cd buildozer-bug-poc
cat < BUILD
my_custom_rule(
name = "my_target",
)
EOF
go install github.com/bazelbuild/buildtools/buildozer@latest
buildozer 'add systems:expr SYSTEMS.SYS1' :my_target
cat BUILD
```

**Actual result**:

The following is added to `:my_target`: `systems = [SYSTeMS.SYS1]`

**Expected behavior**:

The following should be added to `:my_target`: `systems = [SYSTEMS.SYS1]`

**Affected versions**:

* <= 8.5.1: All prebuilt and tagged versions are not affected by this change, as the attribute type system was not yet published in a tagged version.
* latest: This version contains the attribute type system and is affected by this issue.

**Additional information**:
* This issue is reproducible across different machines and environments.
* This issue only occurs if there is a dot '.' somewhere in the expression. If the expression is just SYSTEMS (without a dot), it remains fully capitalized.
* The position of the dot does not matter. If there is a dot anywhere in the identifier chain, the first 'E' is converted to lowercase.

Contributor guide

Open the contributing guide

Research direction

Start by running the provided Buildozer reproduction in a BUILD file, then trace the :expr type handling used by the `buildozer 'add systems:expr SYSTEMS.SYS1' :my_target` entry point. Done means the generated BUILD file preserves `SYSTEMS.SYS1` with its uppercase `E`, including when the expression contains a dot.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
build-system, cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.