Skip to content

bake: avoid early-exit for resolution failures#1605

Merged
jedevc merged 1 commit intodocker:masterfrom
jedevc:bake-fix-errors
Feb 7, 2023
Merged

bake: avoid early-exit for resolution failures#1605
jedevc merged 1 commit intodocker:masterfrom
jedevc:bake-fix-errors

Conversation

@jedevc
Copy link
Collaborator

@jedevc jedevc commented Feb 6, 2023

🐛 Fixes #1586 (however, it looks like there are still some underlying issues with funcCall erroneously detecting contents of those JSON objects as function calls).

With changes made to allow lazy evaluation, we were early exiting if an undefined name was detected, either for a variable or a function.

This had two key implications:

  1. The error messages changed, and became significantly less informative.

    For example, we went from:

    Unknown variable; There is no variable named "FO". Did you mean "FOO"?, and 1 other diagnostic(s)

    To

    Invalid expression; undefined variable "FO"

  2. Any issues in our function detection from funcCalls which cause JSON functions to be erroneously detected cause invalid functions to be resolved, which causes new name resolution errors.

To avoid the above problems, we can defer the error from an undefined name until HCL evaluation - which produces the more informative errors, and does not suffer from incorrectly detecting JSON functions.

With changes made to allow lazy evaluation, we were early exiting if an
undefined name was detected, either for a variable or a function.

This had two key implications:

1. The error messages changed, and became significantly less
   informative.

   For example, we went from:

   > Unknown variable; There is no variable named "FO". Did you mean "FOO"?, and 1 other diagnostic(s)

   To

   > Invalid expression; undefined variable "FO"

2. Any issues in our function detection from funcCalls which cause JSON
   functions to be erroneously detected cause invalid functions to be
   resolved, which causes new name resolution errors.

To avoid the above problems, we can defer the error from an undefined
name until HCL evaluation - which produces the more informative errors,
and does not suffer from incorrectly detecting JSON functions.

Signed-off-by: Justin Chadwell <me@jedevc.com>
@jedevc jedevc merged commit 46fd0a6 into docker:master Feb 7, 2023
@jedevc jedevc deleted the bake-fix-errors branch February 7, 2023 10:36
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.

[bake] Function false positives?

3 participants