HCL Variable Values mixes key-value and JSON format
- Dominant language
- Go
- Stars
- 17k
- Forks
- 2.1k
- Avg merge
- 1d 9h
- Merged PRs (30d)
- 105
Description
### Nomad version
1.8.0
### Issue
If you deploy a job with variables provided by both `-var-file=foo.json` and `NOMAD_VAR_name` environment variables the `HCL Variable Values` section in the WebUI will show both the correct key-value format (env variables) and JSON (`-var-file`). If one tries to edit the job definition and plan it, it results in the following error:
```
Failed to parse job: unable to parse var content: input.hcl:10,1-2: Argument or block definition required; An argument or block definition is required here.
```
The user then has to replace the JSON with the key-value format to fix this.
### Reproduction steps
Deploy a job with both env and `-var-file`:
```bash
echo '{
"domain": "example.com",
"issuer": "https://auth.example.com/realms/example"
}' > foo.json
export NOMAD_VAR_version="3.3.1"
export NOMAD_VAR_commit_author="user "
nomad run -var-file=foo.json some-job.hcl
```
Afterward open the job in the WebUI, edit the definition and try to plan your change.
#### Expected Result
The `HCL Variable Values` section should only show variables in the key-value format:
```yaml
version="3.3.1"
commit_author="user "
domain="example.com"
issuer="https://auth.example.com/realms/example"
```
#### Actual Result
It adds the JSON from `-var-file=foo.json`:
```
version="3.3.1"
commit_author="user "
{
"domain": "example.com",
"issuer": "https://auth.example.com/realms/example"
}
```

Contributor guide
No contributing guide indexed for this repository
Research direction
Start with the WebUI's HCL Variable Values section and the edit-and-plan flow described in the reproduction steps. Reproduce the mixed NOMAD_VAR_name and -var-file case, then verify that the displayed values use only key-value syntax and that planning the edited job succeeds.
Written by the indexing model from the issue text.
Assessment
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100