Skip to content

report invalid global expressions clearly#662

Open
crazy-max wants to merge 2 commits into
docker:masterfrom
crazy-max:validate-global-exp
Open

report invalid global expressions clearly#662
crazy-max wants to merge 2 commits into
docker:masterfrom
crazy-max:validate-global-exp

Conversation

@crazy-max
Copy link
Copy Markdown
Member

fixes #545

Handlebars silently renders missing helpers as empty strings, which made configuration mistakes look like boolean parsing failures. Validating the expression name at the rendering boundary preserves existing behavior for documented expressions while producing a more useful error for unsupported ones.

The global expression map in setGlobalExp now doubles as the allowed expression list, and the parsed Handlebars template is checked inline before compilation.

@crazy-max crazy-max requested a review from tonistiigi May 22, 2026 12:46
@crazy-max crazy-max marked this pull request as ready for review May 22, 2026 12:46
crazy-max added 2 commits May 28, 2026 12:59
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves error reporting for unsupported global Handlebars expressions in metadata inputs, addressing cases where invalid helpers previously rendered as empty strings and produced misleading downstream validation errors.

Changes:

  • Adds an allow-list check for global expressions in setGlobalExp.
  • Throws a clearer error for unsupported global expression names.
  • Adds a regression test for an invalid enable={{is_prerelease}} expression.

Reviewed changes

Copilot reviewed 2 out of 4 changed files in this pull request and generated 1 comment.

File Description
src/meta.ts Adds parsing and validation of global Handlebars expressions before compilation.
__tests__/meta.test.ts Adds coverage for the new invalid global expression error path.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/meta.ts
Comment on lines +486 to +492
for (const node of template.body) {
const statement = node as {type: string; path?: {type: string; original: string}};
if (statement.type !== 'MustacheStatement' || statement.path?.type !== 'PathExpression') {
continue;
}
if (!expressions.includes(statement.path.original)) {
throw new Error(`{{${statement.path.original}}} is not a valid global expression`);
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.

Improve error message for invalid global expression

3 participants