Skip to content

IJ selecting the incorrect Bazel target when debugging a Py test under transition #7196

@andponlin-canva

Description

@andponlin-canva

Description of the bug:

See PR 7198.

Can't launch the debugger from the context menu

In a specific project that uses a pinned Python interpreter (internally using a transition) we see that the following query;

bazel query "same_pkg_direct_rdeps(//...)" --output=label_kind

...brings up...

py_test rule //blah:_test
_transition_py_test rule //blah:test

This query is done by the IJ plugin to understand the Rules in the repo.

Unfortunately when the user chooses to debug a Python file, the selected py_test target is :_test and so the debugger fails to launch because the :_test target is not a real one and you can't run it. A work-around is to keep going to the "Edit Configurations..." manually and modifying the label. This is tedious and difficult to communicate.

The problem can be solved by making the IJ plugin choose the correct one and observe that _transition_py_test is actually a py_test.

Can't find sources for the right target

A further problem comes up around mapping the //blah:test back to the source in order to create a reverse mapping in the plugin from the source to the _transition_pt_test target. This creates a situation where it appears that //blah:test has no sources. Because it has no sources, it is never considered to be the target to debug for a given source file when the user opens the context-menu on the source file.

I suspect that this happens because under Bazel 7 there is a mix of PyInfo from Bazel and PyInfo from rules_python in play and the PyInfo used differs between the :_test and :test targets. The templated python_info.bzl is incorrectly assuming that PyInfo from rules_python is only coming into play on Bazel >8. Because the Python specific logic in intellij_info_impl.bzl is unable to find the right PyInfo on the _transition_py_test kind target, it never performs analysis on its sources.

Which category does this issue belong to?

Intellij

What's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

Please see the comment below for an example project which demonstrates the issue.

Which Intellij IDE are you using? Please provide the specific version.

Checks on UE 2024.1 and 2024.3

What programming languages and tools are you using? Please provide specific versions.

Python 3.10

What Bazel plugin version are you using?

2024.11.19.0.3-api-version-243

Have you found anything relevant by searching the web?

NA

Any other information, logs, or outputs that you want to share?

NA

Metadata

Metadata

Assignees

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions