bazel-contrib / bazel-contrib/rules_oci

oci_load drops empty strings in cmd list

Open
#867 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Starlark
Stars
423
Forks
213
Avg merge
53m
Merged PRs (30d)
1

Description

The `oci_load` rule seems to drop empty strings from the `cmd` list. This doesn't happen with rules_docker `container_image` rule.

The empty string behavior is useful for Java libraries like JCommander that help parse command line args.

### To reproduce

WORKSPACE
```
oci_pull(
name = "distroless_java21",
digest = "sha256:ed5be62a70c5b99708b4ad0fc53bda628d11e46e917f66720fd218cae8fe1568",
image = "gcr.io/distroless/java21-debian12",
)
```

BUILD
```
load("@rules_oci//oci:defs.bzl", "oci_image", "oci_load")

oci_image(
name = "test_image",
base = "@distroless_java21",
cmd = [
"hello",
"",
"goodbye",
"",
],
)

oci_load(
name = "test_image_load",
image = ":test_image",
repo_tags = [
"test_image:latest",
],
)
```

```sh
$ bazel run :test_image_load
$ docker inspect test_image:latest
...
"Config": {
"Cmd": [
"hello",
"goodbye"
],
"Entrypoint": [
"/usr/bin/java",
"-jar"
],
...
```

**Notice the empty strings are missing in the CMD list.**

* rules_oci v2.2.6
* Bazel version 6.5.0
* Docker version 28.4.0, build d8eb465

Contributor guide

Open the contributing guide

Research direction

Start by running the supplied WORKSPACE and BUILD reproduction with Bazel, then inspect the resulting image using docker inspect. Compare oci_load's Cmd output with the declared cmd list and the rules_docker container_image behavior; done means empty strings are preserved in the loaded image's Cmd list.

Written by the indexing model from the issue text.

Assessment

Tech stack
docker
Domain
build-system
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.