Skip to content

key: apply ValueMapper to substituted reference values#382

Merged
unknwon merged 4 commits into
mainfrom
fix-valuemapper-on-references
May 3, 2026
Merged

key: apply ValueMapper to substituted reference values#382
unknwon merged 4 commits into
mainfrom
fix-valuemapper-on-references

Conversation

@unknwon

@unknwon unknwon commented May 3, 2026

Copy link
Copy Markdown
Member

Summary

  • When a key's value contains a %(...)s reference, the substituted text was inserted verbatim from the referenced key's raw value, bypassing ValueMapper. Placeholders like ${ENV_VAR} embedded in a referenced key were never expanded.
  • Fix: substitute via nk.String() so the referenced key goes through its own transformValue (ValueMapper + further reference expansion) before being inlined.
  • Also adds t.Cleanup to a pre-existing test that leaked ValueMapper state into sibling subtests (latent issue surfaced by the fix).

Test plan

  • New TestRecursiveValues subtest: ${...} placeholder inside a referenced key gets mapped after substitution.
  • go test ./... passes.

🤖 Generated with Claude Code

unknwon and others added 4 commits May 2, 2026 21:35
When a key's value contains a %(...)s reference, the substituted text
was inserted verbatim from the referenced key's raw value, bypassing
ValueMapper. As a result, placeholders like ${ENV_VAR} embedded in a
referenced key were never expanded.

Substitute via nk.String() so the referenced key goes through its own
transformValue (ValueMapper + further reference expansion) before being
inlined.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
- Replace deprecated io/ioutil with io and os equivalents.
- Replace deprecated reflect.Ptr alias with reflect.Pointer.
- Use fmt.Fprint(&buf, ...) instead of buf.WriteString(fmt.Sprint(...)).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@unknwon unknwon merged commit 89efed6 into main May 3, 2026
4 checks passed
@unknwon unknwon deleted the fix-valuemapper-on-references branch May 3, 2026 01:44
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