Skip to content

pkg_files: avoid index-out-of-range error (#1070)#1071

Closed
grrtrr wants to merge 1 commit into
bazelbuild:mainfrom
grrtrr:issue_1070
Closed

pkg_files: avoid index-out-of-range error (#1070)#1071
grrtrr wants to merge 1 commit into
bazelbuild:mainfrom
grrtrr:issue_1070

Conversation

@grrtrr

@grrtrr grrtrr commented Jul 11, 2026

Copy link
Copy Markdown

Under the (possible) conditions in #1070, add_from_default_info() fails with:

  File "/home/grenker/.cache/bazel/_bazel_grenker/d2508ebd25597e9a92cadc5f3ae02937/external/rules_pkg/pkg/private/tar/tar.bzl", line 136, column 19, in _pkg_tar_impl
          add_label_list(mapping_context, srcs = ctx.attr.srcs)
  File "/home/grenker/.cache/bazel/_bazel_grenker/d2508ebd25597e9a92cadc5f3ae02937/external/rules_pkg/pkg/private/pkg_files.bzl", line 373, column 34, in add_label_list
          add_from_default_info(
  File "/home/grenker/.cache/bazel/_bazel_grenker/d2508ebd25597e9a92cadc5f3ae02937/external/rules_pkg/pkg/private/pkg_files.bzl", line 440, column 52, in add_from_default_info
          base_file = the_executable or all_files[0]
  Error: index out of range (index is 0, but sequence has 0 elements)

Avoid this condition by returning early. Resolves #1070.

Under the (possible) conditions in bazelbuild#1070, `add_from_default_info()` fails with:
```console
  File "/home/grenker/.cache/bazel/_bazel_grenker/d2508ebd25597e9a92cadc5f3ae02937/external/rules_pkg/pkg/private/tar/tar.bzl", line 136, column 19, in _pkg_tar_impl
          add_label_list(mapping_context, srcs = ctx.attr.srcs)
  File "/home/grenker/.cache/bazel/_bazel_grenker/d2508ebd25597e9a92cadc5f3ae02937/external/rules_pkg/pkg/private/pkg_files.bzl", line 373, column 34, in add_label_list
          add_from_default_info(
  File "/home/grenker/.cache/bazel/_bazel_grenker/d2508ebd25597e9a92cadc5f3ae02937/external/rules_pkg/pkg/private/pkg_files.bzl", line 440, column 52, in add_from_default_info
          base_file = the_executable or all_files[0]
  Error: index out of range (index is 0, but sequence has 0 elements)
```
Avoid this condition by returning early. Resolves bazelbuild#1070.
@grrtrr
grrtrr requested review from aiuto and cgrindel as code owners July 11, 2026 15:15
@grrtrr

grrtrr commented Jul 14, 2026

Copy link
Copy Markdown
Author

Already resolved by 5449272.

@grrtrr grrtrr closed this Jul 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[pkg_files]: index-out-of-range error when src[DefaultInfo].files is empty

2 participants