JetBrains / bazel-bsp

An implementation of the Build Server Protocol for Bazel

Home Page:https://youtrack.jetbrains.com/issues/BAZEL

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

aspects.bzl attempts to access non-existent struct field

bbarnes52 opened this issue · comments

Experiencing the following error:

2022.06.28 18:22:34 ERROR (18:22:34) ^[[31m^[[1mERROR: ^[[0m/Users/brian.barnes/universe/common/lazy/BUILD:7:16: in //.bazelbsp:aspects.bzl%bsp_target_info_aspect aspect on generic_scala_worker rule //common/lazy:lazy-spark_3.0_2.12: ^[[0m
2022.06.28 18:22:34 ERROR Traceback (most recent call last):^[[0m
2022.06.28 18:22:34 ERROR       File "/Users/brian.barnes/universe/.bazelbsp/aspects.bzl", line 475, column 41, in _bsp_target_info_aspect_impl^[[0m
2022.06.28 18:22:34 ERROR               java_target_info = extract_java_info(target, ctx, output_groups)^[[0m
2022.06.28 18:22:34 ERROR       File "/Users/brian.barnes/universe/.bazelbsp/aspects.bzl", line 208, column 40, in extract_java_info^[[0m
2022.06.28 18:22:34 ERROR               java_outputs = provider.outputs.jars^[[0m
2022.06.28 18:22:34 ERROR Error: 'struct' value has no field or method 'jars'^[[0m
2022.06.28 18:22:34 ERROR Available attributes: class_jar, ijar, source_jars^[[0m

The relevant code snippet is reproduced below:

elif hasattr(provider, "outputs") and provider.outputs:
    java_outputs = provider.outputs.jars

Should this instead read:

elif hasattr(provider, "outputs") and provider.outputs and hasattr(provider.outputs, "jars") and provider.outputs.jars:
    java_outputs = provider.outputs.jars

What is your bazel version and what rules are you using for scala?

The scala rules are custom and the scala attribute doesn't implement JavaInfo. My apologies for the noise

nevertheless, having safer aspects would be good - I'll fix it later