hashicorp / hashicorp/nomad

HCL Variable Values mixes key-value and JSON format

Open
#23,926 3 comments 1 reaction 0 assignees View on GitHub
stage/accepted theme/hcl theme/ui type/bug
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"
}
```

![image](https://github.com/user-attachments/assets/7ba4b9d5-0808-460f-a8a7-d46ef978452a)

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.