rules_kotlin icon indicating copy to clipboard operation
rules_kotlin copied to clipboard

`_run_kt_java_builder_actions` attempts to index empty sequence

Open avarun42 opened this issue 2 years ago • 4 comments

Discovered an issue when attempting to update to v1.8-RC-1 — if there are annotation processors but java_infos is empty, the attempt to dereference index 0 of the list of class_jars fails here.

Traceback (most recent call last):
	File "/home/runner/.cache/bazel/_bazel_runner/2e09d596b966b017ceca1b8a16be107a/external/io_bazel_rules_kotlin/kotlin/internal/jvm/impl.bzl", line 262, column 44, in kt_jvm_junit_test_impl
		providers = _kt_jvm_produce_jar_actions(ctx, "kt_jvm_test")
	File "/home/runner/.cache/bazel/_bazel_runner/2e09d596b966b017ceca1b8a16be107a/external/io_bazel_rules_kotlin/kotlin/internal/jvm/compile.bzl", line 493, column 50, in kt_jvm_produce_jar_actions
		outputs_struct = _run_kt_java_builder_actions(
	File "/home/runner/.cache/bazel/_bazel_runner/2e09d596b966b017ceca1b8a16be107a/external/io_bazel_rules_kotlin/kotlin/internal/jvm/compile.bzl", line 752, column 97, in _run_kt_java_builder_actions
		ap_class_jar = [jars.class_jar for outputs in outputs_list for jars in outputs.jars][0],
Error: index out of range (index is 0, but sequence has 0 elements)

avarun42 avatar Feb 02 '23 17:02 avarun42

It's unclear to me what the intent of this code is (why is only one of the class_jars from java_infos used in the first place?) and the usage of the .annotation_processing field of JavaInfo seems deprecated in the first place so I can't provide much further insight here.

avarun42 avatar Feb 06 '23 18:02 avarun42

  • Do you have a quick repro case?
  • What version of bazel are you using? (Part of the joy is that this code covers several bazel versions.)

restingbull avatar Feb 07 '23 02:02 restingbull

Bazel version is 5.3.0. Don't currently have a repro.

avarun42 avatar Feb 07 '23 18:02 avarun42

Also occurs on Bazel 5.4.0 as well

avarun42 avatar Mar 25 '23 21:03 avarun42