bazel-contrib / bazel-contrib/bazel-lib

[Bug]: expand_template FORMATTED_DATE

Open
#827 1 comment 0 reactions 0 assignees View on GitHub
bug need: investigation need: more info
Dominant language
Starlark
Stars
182
Forks
134
Avg merge
1d 46m
Merged PRs (30d)
1

Description

### What happened?

the volatile `FORMATTED_DATE` is not being replaced during expand_template. But `BUILD_TIMESTAMP` does get replaced.

### Version

Development (host) and target OS/architectures:
OSX, darwin, arm64

Output of `bazel --version`:
bazel 7.0.2

Version of the Aspect rules, or other relevant rules from your
`WORKSPACE` or `MODULE.bazel` file:
bazel_dep(name = "aspect_bazel_lib", version = "2.3.0")

Language(s) and/or frameworks involved:

### How to reproduce

```shell
load("@aspect_bazel_lib//lib:expand_template.bzl", "expand_template")

expand_template(
name = "labels",
out = "labels.txt",
stamp = 1,
stamp_substitutions = {
"{{_BUILD_TIME}}": "{{FORMATTED_DATE}}",
},
template = [
"BUILD_TIME={{_BUILD_TIME}}",
],
)

Expected: cat labels.txt
BUILD_TIME=2024 Apr 29 21 21 05 Mon

Actual: cat labels.txt
BUILD_TIME={{FORMATTED_DATE}}
```

### Any other information?

_No response_

Contributor guide

Open the contributing guide

Research direction

Start in lib/expand_template.bzl, especially the expand_template implementation and its stamp_substitutions handling. Run the provided Bazel reproduction and compare labels.txt with the expected BUILD_TIME value; done means FORMATTED_DATE is expanded when nested in a substitution.

Written by the indexing model from the issue text.

Assessment

Domain
build-system
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.