hashicorp / hashicorp/nomad

HCL2 validation fails with: Extra characters after interpolation expression

Open
#11,222 3 comments 3 reactions 0 assignees View on GitHub
stage/needs-investigation theme/hcl type/bug
Dominant language
Go
Stars
17k
Forks
2.1k
Avg merge
1d 9h
Merged PRs (30d)
105

Description

### Nomad version
Output from `nomad version`
Nomad v0.12.7 (6147cb578794cb2d0c35d68fe1791728a09bb081) ( my production env ) **Not** affected
Nomad v1.1.3 (8c0c8140997329136971e66e4c2337dfcf932692) affected
Nomad v1.1.4 affected
Nomad v1.1.5 (117a23d2cdf26a1837b21c84f30c8c0f3441e927) affected

### Operating system and Environment details
Ubuntu 18.04 and 20.04

### Issue
hello,

If a client meta key starts with a number, it breaks the hcl2 validator for a job, hcl1 appears to work fine.

### Reproduction steps
* nomad agent config for this example:
```
client {
enabled = true
meta {
"56net" = "true"
"web" = "true"
"balancer" = "false"
}
}
```
* a dummy job file
```
# vi: tabstop=4 shiftwidth=4 expandtab
job "ajob" {
datacenters = ["dc1"]
type = "service"

constraint {
attribute = "${meta.56net}" /* <== this one */
value = "true"
}

group "ahappylittlegroup" {
count = 1
constraint {
operator = "distinct_hosts"
value = "true"
}
task "dummy" {
driver = "docker"
config {
image = "whatever"
network_mode="host"
}
resources {
memory = 2048
cpu = 400
}
}
}
}
```
* Execution
`nomad job validate dummy.nomad`

#### Expected Result
`Job validation successful` ( with green happy characters )

#### Actual Result
```
Error getting job struct: Failed to parse using HCL 2. Use the HCL 1 parser with `nomad run -hcl1`, or address the following issues:
dummy.nomad:7,33-36: Extra characters after interpolation expression; Expected a closing brace to end the interpolation expression, but found extra characters.
```

I also posted this at `https://discuss.hashicorp.com/t/extra-characters-after-interpolation-expression/29726`
and another user was able to reproduce this as well.

Thank you

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reproducing the issue with the supplied client meta configuration and dummy job, then run `nomad job validate dummy.nomad` against the affected Nomad versions. Done means the HCL2 validator accepts `${meta.56net}` and reports successful job validation without requiring the HCL1 option.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
devops, infrastructure
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.