Skip to content

Fix: Defer validate_resolved_files in hydrate_sources to support …#23465

Open
thiago-carbonera wants to merge 1 commit into
pantsbuild:mainfrom
thiago-carbonera:fix/single-source-hydration
Open

Fix: Defer validate_resolved_files in hydrate_sources to support …#23465
thiago-carbonera wants to merge 1 commit into
pantsbuild:mainfrom
thiago-carbonera:fix/single-source-hydration

Conversation

@thiago-carbonera

Copy link
Copy Markdown
Contributor

Fixes #23015

Problem

SingleSourceFields that rely on target generation/codegen currently fail to hydrate. This happens because validate_resolved_files is called immediately after glob expansion, before the actual code generation (generate_sources) takes place. Since SingleSourceField strictly expects exactly 1 file, this premature validation fails because the generated file doesn't exist yet.

Solution

Refactored the execution order inside hydrate_sources (src/python/pants/engine/internals/graph.py) to defer file validation:

  • If codegen is not in use, the validation happens normally on the initial snapshot as before.
  • If codegen is enabled, the validation is skipped initially and only called on generated_sources.snapshot.files after the generate_sources await completes.

Also added the corresponding release note to docs/notes/2.33.x.md.

…generated SingleSourceFields

Fixes pantsbuild#23015

Signed-off-by: Thiago Riemma Carbonera <thiagoriemma@gmail.com>
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.

SingleSourceField can't be hydrated

1 participant