Report missing generated source files during sync instead of dropping them silently#400
Closed
Frank Portman (FrankPortman) wants to merge 1 commit into
Closed
Conversation
Missing generated sources were silently dropped by AspectBazelProjectMapper, which makes it hard to diagnose why generated code (e.g. Scala sources produced by a genrule) is not indexed by the IDE after a sync. Log a warning for them, like for missing regular source files.
Author
|
Companion aspect fix is up: JetBrains/intellij-aspect#143 — once merged, the |
Contributor
|
Thank you for the proposed PR. Generally I accept it, however we already have this implemented in a bit different way, and the implementation is in the merge queue. I close the PR, and you can await the implementation in a week |
Author
|
thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
While debugging why code-generated sources do not resolve in the IDE (red squiggles), I traced two symptom classes through the sync pipeline:
genrule-produced.scalafile fed intoscala_library.srcsreachesTargetIdeInfo.srcsListwithis_source = false, but is not part of any output group in the aspect. A normal Resync (buildProject = false) only materializes theintellij-infoandintellij-syncoutput groups, so the generated file never exists on disk at mapping time.AspectBazelProjectMapper.resolveSourceSetthen drops the file becausepath.exists()is false — andMissingFilesReporter.adddeliberately stays silent for generated sources, so there is no trace of the drop anywhere. (Generated Python viapy_libraryworks only becausepy_info.bzlregistersPyInfo.transitive_sourcesin the sync output group.)This PR
Makes the failure observable:
MissingFilesReporternow also logs a warning for generated source files that were not materialized during sync, instead of silently ignoring them. This would have pointed straight at the root cause.Companion fix
The root causes live in the aspect (
JetBrains/intellij-aspect, consumed via theintellij_aspect_sdkpin inMODULE.bazel):modules/scala_info.bzldetects Scala targets solely by thescala_/thrift_kind prefix, so custom Scala rules get noscala_target_info(unlike Java/Kotlin/Python, which detect by provider).modules/python_info.bzlonly falls back to PyInfo/runfiles whensrcsis completely empty, so a custom code-generator rule providingPyInfowhosesrcsholds generator inputs (templates/protos) exposes no Python sources at all.I have those fixes plus regression tests ready (new fixture tests fail before / pass after;
//testing/tests/{python,scala,java,kotlin}pass). Once that lands, theintellij_aspect_sdkcommit pin here needs a bump to pick it up. Happy to open that PR against intellij-aspect as well.