Skip to content

fix(pkl-schema): emit hints for fields under SubResources without a FieldHint#428

Merged
JeroenSoeters merged 1 commit into
mainfrom
fix/pkl-flattener-3-level
Apr 22, 2026
Merged

fix(pkl-schema): emit hints for fields under SubResources without a FieldHint#428
JeroenSoeters merged 1 commit into
mainfrom
fix/pkl-flattener-3-level

Conversation

@JeroenSoeters
Copy link
Copy Markdown
Collaborator

Summary

  • The PKL hints flattener in internal/schema/pkl/schema/formae.pkl skipped any nested SubResource-typed field whose declaration did not carry its own @FieldHint. @FieldHint annotations on fields three or more levels deep — e.g. Volumes.EFSVolumeConfiguration.RootDirectory on AWS::ECS::TaskDefinition — never reached the compiled schema.
  • Consequence: the recursive patch-time stripper had no hint path to walk, AWS-populated provider defaults stayed in stored state, and any createOnly ancestor triggered a spurious resource replacement on reapply. This is the root cause behind the lgtm-task spurious-replace investigation on fix/ecs-spurious-replace-investigation and the reason the plugin-side annotation added in formae-plugin-aws#47 appeared to have no effect end-to-end.
  • Fix: descend into any SubResource-typed field regardless of whether the declaration has an @FieldHint, and fall back to the default key transformation when no FieldHint is present to supply outputField. Same change in both hints() and the recursive subHintsWithVisited().
  • Regression test added under internal/schema/pkl/schema/tests/formae.pkl that models the ECS pattern (outer field annotated, intermediate SubResource field unannotated, deepest field annotated) and asserts the 3-level hint emits with its annotations intact. The full test-pkl, lint, and test-all suites pass.

…ieldHint

The hints flattener skipped any nested SubResource-typed field whose
declaration did not carry its own @FieldHint. Annotations on fields
three or more levels deep (e.g. Volumes.EFSVolumeConfiguration.RootDirectory)
never reached the compiled schema, so the recursive patch-time stripper
had no hint path to walk and AWS-populated provider defaults stayed in
the stored state — causing spurious replacements on reapply of
createOnly ancestors.

Descend into any SubResource-typed field regardless of whether the
declaration is annotated, and fall back to the default key
transformation when no FieldHint is present to supply outputField.

Adds a regression test that reproduces the ECS TaskDefinition
Volumes.EFSVolumeConfiguration.RootDirectory pattern: outer field
annotated, intermediate field unannotated, deepest field annotated.
Previously the 3-level hint was missing; now it emits.
@JeroenSoeters JeroenSoeters merged commit bf70b0b into main Apr 22, 2026
25 checks passed
@JeroenSoeters JeroenSoeters deleted the fix/pkl-flattener-3-level branch April 22, 2026 21:45
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.

1 participant