Skip to content
This repository has been archived by the owner on Jan 8, 2024. It is now read-only.

Backport of config/funcs: template functions to return valid ArgError values into release/0.4.x #1688

Conversation

hc-github-team-waypoint
Copy link
Collaborator

Backport

This PR is auto-generated from #1679 to be assessed for backporting due to the inclusion of the label backport/0.4.x.

The below text is copied from the body of the original PR.


The template functions are all defined with a variadic parameter to collect zero or more vars maps, but that means we need to be careful to handle the case where there are no vars maps at all.

This code seems to have originally been derived from Terraform's templatefile which has a non-variadic `vars, and so Terraform was correct to assume that argument 1 would always be present. Since Waypoint's version allows omitting it, we'll handle that situation by putting the "blame" on the template argument instead, to suggest that it's invalid to refer to any variables inside a template call that doesn't have any variables.

The previous incorrect result was originally a panic due to violating the contract HCL expects for function.ArgError, although hashicorp/hcl#472 addressed that by just returning a less-specific error message in that case. This fix therefore boils down to just highlighting a more specific part of the input in the error message HCL will ultimately return.


This originally arose in #1675. With this change, the input from that issue should return the new error message I added here and the error message should identify the "${path.app}/job.hcl.tpl" argument specifically as the expression that caused the error.

@hc-github-team-waypoint hc-github-team-waypoint merged commit 682f604 into release/0.4.x Jun 22, 2021
@hc-github-team-waypoint hc-github-team-waypoint deleted the backport/b-templatefile-no-vars/absolutely-divine-oriole branch June 22, 2021 15:12
@github-actions github-actions bot added the core label Jun 22, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants