# How to read a contradiction error and find both values that clash

> Turn an aontu vet failure into the two positions that clash, follow the include chain to the value an environment set, and fix that file, not the shared definition.

Source: https://voxgig.com/howto/read-a-config-contradiction-error

- Audience: platform-team
- Level: beginner
- Verified: 2026-11-30
- Published: 2026-11-30

## Short answer

Run `aontu vet` with the shared definition as the schema and one environment's entry file as the data. Each finding names two sites: `data`, the value the environment supplied, and `schema`, the definition it failed. Follow the data site's include chain from the entry file and edit that value. Loosening the schema line also clears the error, but it changes the rule for every environment that shares the definition.

---
## You will need

Node 22 or later, and aontu installed from npm in the config's directory. Verified 2026-11-30
against Node 22.23.5 and aontu 0.76.3. The aontu package and its `@tabnas` dependencies declare
`engines.node` as `>=24`, so `npm ci` prints `EBADENGINE` warnings under Node 22 and installs
them anyway. Every command here calls `node_modules/.bin/aontu`, so a different `aontu` on your
`PATH` never answers.

## Approaches compared

| Approach | When it fits | What it costs you | When to pick something else |
| --- | --- | --- | --- |
| [aontu `vet`](https://aontu.dev/docs/reference-api/#aontu-vet) | The layers are aontu files, and you want each site labeled as data or schema | Another language for contributors, and a data site that named no entry file on this config | The config already lives in CUE or Nickel, where both positions print too |
| [CUE `cue vet`](https://cuelang.org/docs/reference/command/cue-help-vet/) | The config is CUE, with the layers listed as files on the command line | Two positions with no label on this clash, so you decide which one is the definition | You want the report itself to say which side an environment supplied |
| [Dhall `dhall type`](https://hackage.haskell.org/package/dhall-1.42.2/docs/Dhall-Tutorial.html) | The config is Dhall, and types plus `assert` expressions are the checks you need | No number type takes a range, and the tutorial's assertion error gives one source position for both values | The clash is between two values, and you need both positions printed |
| [Nickel contracts](https://nickel-lang.org/user-manual/contracts/#blame-locations) | The config is Nickel, with a schema record of contracts merged over the layers | Named the last field, `port`, rather than the path, beside both file positions here | Several records share a field name, so the path decides which one broke |

aontu and Nickel printed both positions of this clash, and so did CUE, with no label on either
line. Nickel named only the last field, which is cheap to read until two records both hold a
`port`. The number types in the
[Dhall standard](https://github.com/dhall-lang/dhall-lang/blob/master/standard/type-inference.md)
take no range, so a port rule becomes an `assert` you write, and the tutorial's failed assertion
shows one source position under an import chain.

Voxgig maintains aontu. It is one of four options here, not the recommendation.

## Read the error the deploy job prints

The sample config has a shared definition, `defs/service.aontu`, with `port: integer &
min(1024) & max(65535)`,[^1] and three environments under `envs/`. `deploy-prod.aontu` includes
the definition and production's entry file, which is what a deploy job evaluates. The full error
carries a hint and a source frame for each side, so this filters it to the positions:

```bash
node_modules/.bin/aontu deploy-prod.aontu 2>&1 | grep -E 'Cannot unify value|-->'
```

```text output
[aontu/constraint]: Cannot unify values at path $.server.port
 Cannot unify value: integer&min(1024)&max(65535) with value: 443
  --> defs/service.aontu:3:19
 Cannot unify value: 443 with value: integer&min(1024)&max(65535)
  --> envs/lb/hotfix-443.aontu:2:15
```

Both sides are there. The definition comes first, and it is the file most readers recognize, so
it is the one they open. Read the second frame before you edit anything: it names the value, `443`,
and the file that wrote it.

## Ask vet which side an environment supplied

`aontu vet` takes the definition and the data as separate arguments, so it can label each site
by where it came from:

```bash
node_modules/.bin/aontu vet defs/service.aontu envs/prod.aontu
```

```text output
verdict: invalid

$.server.port: constraint [conflict]
  [aontu/constraint]: Cannot unify values at path $.server.port
  expected: integer&min(1024)&max(65535)
  actual:   443
  data: envs/lb/hotfix-443.aontu:2:15 (443)
  schema: defs/service.aontu:3:19 (integer&min(1024)&max(65535))
```

The order has flipped. The reference documents it: vet lists the data site first because that is
the one to edit.[^2] It exits 1 for a contradiction, and `--format json` gives the same two
sites as objects with `file`, `row`, `col` and `role`.

The data site names `envs/lb/hotfix-443.aontu`. Nothing in `envs/prod.aontu` mentions that
file, and vet does not print how it was reached.

## Follow the include chain to the value

`clash.mjs` runs vet once per environment and reads the JSON report. It walks the includes of
each entry file breadth first, recording the file that included each one, so it can print the
chain back to the entry. Then it compares the files it found with the list aontu's own parser
returns for that entry:

```js title="clash.mjs"
export function includeTree(entry) {
  const root = resolve(entry)
  const parent = new Map([[root, null]])
  const queue = [root]
  while (queue.length > 0) {
    const file = queue.shift()
    if (!existsSync(file)) throw new Error(`include not found: ${file}`)
    const text = readFileSync(file, 'utf8').split('\n').map(stripComment).join('\n')
    for (const m of text.matchAll(INCLUDE)) {
      const spec = m[1] ?? m[2] ?? m[3]
      if (BUNDLED.test(spec)) continue
      const child = resolve(dirname(file), spec)
      if (!parent.has(child)) {
        parent.set(child, file)
        queue.push(child)
      }
    }
  }
  const walked = [...parent.keys()].filter((f) => f !== root).sort()
  const loaded = [...new Set(engineIncludes(root))].sort()
  if (walked.join('\n') !== loaded.join('\n')) {
    throw new Error(`the walker and aontu disagree on the includes of ${entry}`)
  }
  return parent
}
```

A missing include throws, and so does a file list that differs from the parser's, because a
short or wrong chain points at the wrong owner. Run it over all three environments:

```bash
node clash.mjs defs/service.aontu envs/dev.aontu envs/staging.aontu envs/prod.aontu
```

```text output
envs/dev.aontu  valid
envs/staging.aontu  valid
envs/prod.aontu  invalid
  $.server.port  constraint
    data   envs/lb/hotfix-443.aontu:2:15  443
      via envs/prod.aontu > envs/regions/eu-west.aontu > envs/lb/public.aontu > envs/lb/hotfix-443.aontu
      reached by 1 of 3 environments, 0 of the others vet valid
    schema defs/service.aontu:3:19  integer&min(1024)&max(65535)
      reached by 3 of 3 environments, 2 of the others vet valid
```

Two environments meet the same definition and pass, so the definition alone produces no clash.
`hotfix-443.aontu` is reached by production only, three includes from its entry file. That file is the
one to change, and the chain shows which layer brought it in: the load balancer layer.

## Check it worked

`fixes.mjs` applies each candidate fix to a scratch copy, then vets production and an overlay
that asks for port 80:

```bash
node fixes.mjs
```

```text output
loosen the shared definition: defs/service.aontu, min(1024) -> min(1)
  envs/prod.aontu      valid
  a port 80 overlay    valid
change the hotfix production reaches: envs/lb/hotfix-443.aontu, port: 443 -> port: 8443
  envs/prod.aontu      valid
  a port 80 overlay    invalid
```

Both fixes turn production `valid`, but the first also accepts port 80, which the definition
exists to refuse. The test pins the two positions, the chain, the result of each fix, and the
walker's answer for each include form aontu loads:

```bash
node --test clash.test.mjs
```

```text output
1..12
# tests 12
# suites 0
# pass 12
# fail 0
# cancelled 0
# skipped 0
# todo 0
# duration_ms 5566.302667
```

## When it goes wrong

A later environment binds a port the definition used to refuse, after a fix that turned the build
green. Someone edited the schema site because it came first in the evaluation error. Revert it,
and edit the data site the vet report names.

Vet given several data files reports a data site with no entry file. With
`envs/dev.aontu envs/staging.aontu envs/prod.aontu` in one call, the finding still names only
`envs/lb/hotfix-443.aontu`. Vet one entry per call, as `clash.mjs` does, so each verdict belongs to
one environment.

The walker stops with `the walker and aontu disagree`. The entry uses an include form the walker
does not read, or a string holds text shaped like an include. Read the entry by hand, then teach
the walker the form and add a test for it.

## Read the same clash in three other languages

`record.sh` ran the same layers, written in CUE and in Nickel, once each. The page's checks read
what they printed rather than running either tool:

```bash
cat records/cue-vet.txt
```

```text output
# cue version v0.18.0
# exit status 1
server.port: invalid value 443 (out of bound >=1024):
    ./defs/service.cue:5:17
    ./envs/lb/hotfix-443.cue:4:15
```

```bash
cat records/nickel-export.txt
```

```text output
# nickel-lang-cli nickel 1.18.0 (rev cargore)
# exit status 1
error: contract broken by the value of `port`
  ┌─ defs/service.ncl:5:12
  │
5 │     port | Port,
  │            ---- expected type
  │
  ┌─ envs/lb/hotfix-443.ncl:2:17
  │
2 │ { server.port = 443 }
  │                 ^^^ applied to this expression
```

CUE printed the path and both positions, with nothing to say which is the definition. Nickel
labeled the two as `expected type` and `applied to this expression`, which does the job vet's
roles do, and named the field as `port` alone. Neither printed an include chain. CUE has none
to print, since every layer is on its command line. Nickel reached `hotfix-443.ncl` through three
imports from `prod.ncl` and named neither `prod.ncl` nor the files between.

A position can still go missing. Nickel's
[guide to blame locations](https://nickel-lang.org/user-manual/contracts/#blame-locations) shows a
contract that checks a whole record at once, and its error blames the record rather than the
field inside it.

Dhall was not run. Its [tutorial](https://hackage.haskell.org/package/dhall-1.42.2/docs/Dhall-Tutorial.html)
shows a failed `assert` in an imported file as an `↳ ./test.dhall` line, the message
`Error: Assertion failed`, and a diff of the two normal forms. It then gives the failing
expression's position, `./test.dhall:7:16`, and the import's, `(input):1:1`.[^3]

## When not to do this

Do not loosen a shared definition to clear one environment's error. The definition is a rule
every environment meets, and the two passing environments show the rule holds.

Do not move a CUE or Nickel config into aontu for the `data` and `schema` labels. Both tools
printed the same two positions here, so the label is all the move would buy.

Do not trust a chain walker that reads includes with a regular expression and never checks
itself. aontu loaded single quotes, backticks and a space after the `@` here, and the walker
only knows the forms its test lists. The comparison with the parser's own list is what catches
the next one.

Do not vet every environment in one call when you need to know which one failed. Pass one entry
per call, or use `--format json` and keep the entry beside each report.

## Related how-tos

- [Explain why a unified config has a given value](/howto/explain-why-a-unified-config-value)

- [Vet an aontu model for contradictions before you generate](/howto/vet-a-model-file-before-you-generate)

- [Merge nested config objects with predictable precedence](/howto/merge-nested-config-objects-with-precedence)

- [Read a TOML file the same way in a Python app and a Go app](/howto/read-toml-config-in-python-and-go)

## Last verified

Verified 2026-11-30 against Node 22.23.5 and aontu 0.76.3, installed from npm in the sample
directory. Every output block is what the command preceding it printed. The CUE and Nickel
records came from cue v0.18.0 and Nickel 1.18.0, run once by `record.sh`; the page's checks do
not run them. Dhall was not run: everything said about it here is read from its tutorial and its
language standard.

[^1]: The floor of 1024 is the edge of a range.
[RFC 6335](https://www.rfc-editor.org/rfc/rfc6335.html#section-6) divides each transport's
16-bit port space into System Ports from 0 to 1023, User Ports from 1024 to 49151, and Dynamic
Ports from 49152 up. It cites RFC 1340 for the split. Each range carries more than one name, so
443 is a System Port and a Well Known Port at once.

[^2]: The [vet reference](https://aontu.dev/docs/reference-api/#aontu-vet) contrasts that order
with the source order a single-document error follows. One clash therefore prints its
two sites in two orders, depending on whether vet or a plain evaluation found it, as the first
two commands on this page show.

[^3]: The arrow is how Dhall draws an import chain. The
[same tutorial](https://hackage.haskell.org/package/dhall-1.42.2/docs/Dhall-Tutorial.html)
uses it for a cycle, with `↳ ./file1` followed by an indented `↳ ./file2` and then `Cyclic import:
./file1`, so the chain makes up most of the error.