Skip to content

fix(template): extract variables nested in required-error messages - #936

Open
00200200 wants to merge 1 commit into
compose-spec:mainfrom
00200200:934-extract-variables-required-nested
Open

00200200 wants to merge 1 commit into
compose-spec:mainfrom
00200200:934-extract-variables-required-nested

Conversation

@00200200

Copy link
Copy Markdown

ExtractVariables already walked nested interpolations in :- / - and :+ / + operands, but not in the :? / ? error message. ${U:?${B}} and ${U?$B} therefore reported only U, while ${U:-${B}} / ${U:+${B}} reported both, even though Substitute expands B when building the missing-variable error.

The spec lists ${VARIABLE?$FOO} among nested interpolations (12-interpolation.md). Recurse into the required-error operand the same way as the default and presence operands.

Fixes #934

Tests: go test ./template/ -run TestExtractVariables (new cases nested-in-required-error-braced, nested-in-required-error-unbraced, nested-default-in-required-error); go test ./... green.

ExtractVariables already walked :- and :+ operands, but skipped the
:? / ? error message, so ${U:?${B}} and ${U?$B} reported only U.
Substitute already expands that nested variable; collect it too.

Fixes compose-spec#934

Signed-off-by: Michał Furgała <83299832+00200200@users.noreply.github.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.

ExtractVariables does not report a variable used inside a ${VAR:?…} message

1 participant