Skip to main content

Templates: error codes

The expander shows a TPL code when it cannot expand a template. Each code below has a sample: the configuration with the mistake, the fix and the exact message. The tests of the expander run each sample, so the message is the one that you see. The Error codes page lists the codes of the whole gateway.

TPL-E001​

use: names a template that templates: does not define.

Fix: Correct the name, or add the template.

# TPL-E001 - `use:` names a template that `templates:` does not define.
# The fix: Correct the name, or add the template.
templates:
Pump:
instances:
- { browseName: P1, typeDefinition: ua:BaseObjectType, componentOf: /ua:Objects }
instances:
- expand:
use: Pmp # The mistake: the template is "Pump".

The message:

TPL-E001 error instances[0]/Pmp: no template `Pmp` - templates: Pump

TPL-E002​

An expression reads a name that is not in its scope. A template sees only its params and parent.

Fix: Declare the value as a param, and give it in with: or in the record.

# TPL-E002 - An expression reads a name that is not in its scope. A template sees only its params and `parent`.
# The fix: Declare the value as a param, and give it in `with:` or in the record.
templates:
Tank:
params: { id: { type: string } }
instances:
- browseName: "${id}"
nodeId: "s=Tank${index}" # The mistake: index is not a param of Tank.
typeDefinition: ua:BaseObjectType
componentOf: /ua:Objects
instances:
- expand: { over: [{ id: T1 }], use: Tank }

The message:

TPL-E002 error instances[0]/Tank[T1]: unknown variable `index` in ${index} - in scope: id

TPL-E003​

A param without a default gets no value.

Fix: Give the value in with: or in the record, or give the param a default.

# TPL-E003 - A param without a default gets no value.
# The fix: Give the value in `with:` or in the record, or give the param a default.
templates:
Tank:
params: { id: { type: string } }
instances:
- { browseName: "${id}", typeDefinition: ua:BaseObjectType, componentOf: /ua:Objects }
instances:
- expand: { use: Tank } # The mistake: no value for id.

The message:

TPL-E003 error instances[0]/Tank: template `Tank`: param `id` is required - pass it in `with:` or the record, or give it a default

TPL-E004​

The same name comes from the with: of the block and from a record.

Fix: Give the value one time only.

# TPL-E004 - The same name comes from the `with:` of the block and from a record.
# The fix: Give the value one time only.
templates:
Tank:
params: { id: { type: string } }
instances:
- { browseName: "${id}", typeDefinition: ua:BaseObjectType, componentOf: /ua:Objects }
instances:
- expand:
with: { id: T0 } # The mistake: id is also in the record.
over: [{ id: T1 }]
use: Tank

The message:

TPL-E004 error instances[0]: `id` comes from the block's `with:` and from the record: give it once

TPL-E005​

A template uses itself, directly or through other templates.

Fix: Remove the loop.

# TPL-E005 - A template uses itself, directly or through other templates.
# The fix: Remove the loop.
templates:
A: [B]
B: [A] # The mistake: B uses A, and A uses B.
instances:
- expand: { use: A }

The message:

TPL-E005 error instances[0]/A/B/A: template `A` uses itself: A → B → A

TPL-E006​

A value does not have the type of its param, or is not in its enum list.

Fix: Correct the value.

# TPL-E006 - A value does not have the type of its param, or is not in its enum list.
# The fix: Correct the value.
templates:
Motor:
params: { id: { type: string }, power: { type: number } }
instances:
- { browseName: "${id}", typeDefinition: ua:BaseObjectType, componentOf: /ua:Objects }
instances:
- expand:
over: [{ id: M1, power: high }] # The mistake: power is a number.
use: Motor

The message:

TPL-E006 error instances[0]/Motor[M1]: template `Motor`: param `power` expects a number, got "high"

TPL-E007​

A template takes a counter that no enclosing block declares.

Fix: Declare the counter in counters: of the block that uses the template.

# TPL-E007 - A template takes a counter that no enclosing block declares.
# The fix: Declare the counter in `counters:` of the block that uses the template.
templates:
Door:
counter: { door: n }
instances:
- { browseName: "Door${n}", typeDefinition: ua:BaseObjectType, componentOf: /ua:Objects }
instances:
- expand: { use: Door } # The mistake: no counters: { door: ... } here.

The message:

TPL-E007 error instances[0]/Door: template `Door` takes counter `door`, which no enclosing block declares in `counters:`

TPL-E008​

Two instances get the same browse path or the same node id after expansion.

Fix: Use a counter, an index or a param in the browseName and in the nodeId.

# TPL-E008 - Two instances get the same browse path or the same node id after expansion.
# The fix: Use a counter, an index or a param in the browseName and in the nodeId.
templates:
Pump:
instances:
- { browseName: Pump, nodeId: s=Pump, typeDefinition: ua:BaseObjectType, componentOf: /ua:Objects }
instances:
- expand: { repeat: 2, use: Pump } # The mistake: the two pumps have the same name.

The message:

TPL-E008 error instances[0]/Pump[1], instances[0]/Pump[2]: browse path /ua:Objects/Pump is created 2 times
TPL-E008 error instances[0]/Pump[1], instances[0]/Pump[2]: node id s=Pump is given to 2 instances

TPL-E009​

A $Name anchor names a browseName that the expansion gave to more than one instance.

Fix: Start the path at a unique name and go down from there: $Station/P1/ASD01.

# TPL-E009 - A `$Name` anchor names a browseName that the expansion gave to more than one instance.
# The fix: Start the path at a unique name and go down from there: `$Station/P1/ASD01`.
templates:
Door:
instances:
- { browseName: ASD01, typeDefinition: ua:BaseObjectType, componentOf: "${parent}" }
instances:
- { browseName: P1, typeDefinition: ua:BaseObjectType, organizedBy: /ua:Objects }
- { browseName: P2, typeDefinition: ua:BaseObjectType, organizedBy: /ua:Objects }
- expand: { parent: $P1, use: Door }
- expand: { parent: $P2, use: Door }
- { browseName: Probe, dataType: ua:Double, componentOf: $ASD01 } # The mistake: two instances are ASD01.

The message:

TPL-E009 error instances[4]: `$ASD01`: $ASD01 names 2 instances; anchor on a unique name and walk down (`$Station/…/ASD01`)

TPL-E010​

jsonata cannot read or evaluate an expression, or the expression uses $now, $millis, $random or $eval.

Fix: Correct the expression. An expansion must give the same result each time.

# TPL-E010 - jsonata cannot read or evaluate an expression, or the expression uses `$now`, `$millis`, `$random` or `$eval`.
# The fix: Correct the expression. An expansion must give the same result each time.
templates:
Log:
instances:
- browseName: "Log${$now()}" # The mistake: the clock is not allowed.
typeDefinition: ua:BaseObjectType
componentOf: /ua:Objects
instances:
- expand: { use: Log }

The message:

TPL-E010 error instances[0]/Log: ${$now()}: $now() is not allowed in templates: an expansion must give the same result every time

TPL-E011​

A record, or the with: of a layout entry, gives a value for a param that the template does not declare.

Fix: Correct the name of the param.

# TPL-E011 - A record, or the `with:` of a layout entry, gives a value for a param that the template does not declare.
# The fix: Correct the name of the param.
templates:
Tank:
params: { id: { type: string } }
instances:
- { browseName: "${id}", typeDefinition: ua:BaseObjectType, componentOf: /ua:Objects }
instances:
- expand:
over: [{ id: T1, volum: 50 }] # The mistake: Tank has no param volum.
use: Tank

The message:

TPL-E011 error instances[0]/Tank[T1]: template `Tank` has no param `volum` - params: id

TPL-E012​

repeat: does not give a whole number of zero or more.

Fix: Give a whole number, or an expression that gives one.

# TPL-E012 - `repeat:` does not give a whole number of zero or more.
# The fix: Give a whole number, or an expression that gives one.
instances:
- expand:
repeat: -1 # The mistake: a negative count.
instances:
- { browseName: X, typeDefinition: ua:BaseObjectType, componentOf: /ua:Objects }

The message:

TPL-E012 error instances[0]: `repeat:` must be a whole number of zero or more, got -1

TPL-E013​

A table has a column that no param matches, or has no column for a required param.

Fix: Correct the header line of the table.

# TPL-E013 - A table has a column that no param matches, or has no column for a required param.
# The fix: Correct the header line of the table.
templates:
Tank:
params: { id: { type: string }, capacity: { type: number } }
instances:
- { browseName: "${id}", typeDefinition: ua:BaseObjectType, componentOf: /ua:Objects }
instances:
- expand:
over: { file: tanks.csv } # The mistake: the header says "capacit".
use: Tank

tanks.csv:

id,capacit
T1,50

The message:

TPL-E013 error tanks.csv:1: column 2 "capacit" matches no param - params: id, capacity
TPL-E013 error tanks.csv:1: no column for the required param `capacity`

TPL-E014​

A cell of a table cannot be read as the type of its param.

Fix: Correct the cell. For a decimal comma, declare decimalSeparator: "," and delimiter: ";".

# TPL-E014 - A cell of a table cannot be read as the type of its param.
# The fix: Correct the cell. For a decimal comma, declare `decimalSeparator: ","` and `delimiter: ";"`.
templates:
Tank:
params: { id: { type: string }, capacity: { type: number } }
instances:
- { browseName: "${id}", typeDefinition: ua:BaseObjectType, componentOf: /ua:Objects }
instances:
- expand:
over: { file: tanks.csv } # The mistake: line 2 has "5O" (a letter O).
use: Tank

tanks.csv:

id,capacity
T1,5O

The message:

TPL-E014 error tanks.csv:2: column capacity: "5O" is not a number

TPL-E015​

The expander cannot read a table file.

Fix: Put the table in the folder of the configuration file, or below it, and give a relative path.

# TPL-E015 - The expander cannot read a table file.
# The fix: Put the table in the folder of the configuration file, or below it, and give a relative path.
templates:
Tank:
params: { id: { type: string } }
instances:
- { browseName: "${id}", typeDefinition: ua:BaseObjectType, componentOf: /ua:Objects }
instances:
- expand:
over: { file: missing.csv } # The mistake: the file does not exist.
use: Tank

The message:

TPL-E015 error instances[0]: cannot read missing.csv: file not found: missing.csv

TPL-E016​

A template or a block does not have the correct shape.

Fix: Correct the definition. The schema of the configuration shows each key.

# TPL-E016 - A template or a block does not have the correct shape.
# The fix: Correct the definition. The schema of the configuration shows each key.
instances:
- expand:
counters: { door: { start: 1, format: "##" } } # The mistake: a format is a run of "0", like "00".
instances:
- { browseName: X, typeDefinition: ua:BaseObjectType, componentOf: /ua:Objects }

The message:

TPL-E016 error instances[0]: counter `door`: format must be a run of "0" (like "00"), got "##"

TPL-E017​

An override names a browse path or a node id that no instance has after expansion.

Fix: Write the path as dump-config prints it, <parent>/<browseName>, or the node id. Remove the override when its instance is gone.

# TPL-E017 - An override names a browse path or a node id that no instance has after expansion.
# The fix: Write the path as dump-config prints it, `<parent>/<browseName>`, or the node id. Remove the override when its instance is gone.
templates:
Door:
counter: { door: n }
instances:
- { browseName: "D${n}", typeDefinition: ua:BaseObjectType, componentOf: /ua:Objects }
instances:
- expand:
counters: { door: { start: 1, format: "00" } }
layout: [{ use: Door, repeat: 2 }]
overrides:
/ua:Objects/D07: # The mistake: there are two doors only.
description: no left switch

The message:

TPL-E017 error overrides[/ua:Objects/D07]: no instance has the browse path or node id /ua:Objects/D07 - write the path as dump-config prints it (<parent>/<browseName>), or the node id

TPL-W001​

A value has more digits than its format. The expander keeps the value whole. This is a warning.

Fix: Make the format wider.

# TPL-W001 - A value has more digits than its format. The expander keeps the value whole. This is a warning.
# The fix: Make the format wider.
templates:
Door:
counter: { door: n }
instances:
- { browseName: "Door${n}", typeDefinition: ua:BaseObjectType, componentOf: /ua:Objects }
instances:
- expand:
counters: { door: { start: 99, format: "00" } } # The mistake: 100 does not fit in "00".
layout: [{ use: Door, repeat: 2 }]

The message:

TPL-W001 warning instances[0]: 100 is wider than the format "00": kept whole

TPL-W002​

A block that reads a table also uses index. A moved or added row changes every value after it. This is a warning.

Fix: Put the value in a column of the table.

# TPL-W002 - A block that reads a table also uses `index`. A moved or added row changes every value after it. This is a warning.
# The fix: Put the value in a column of the table.
templates:
Tank:
params: { id: { type: string } }
instances:
- { browseName: "${id}", typeDefinition: ua:BaseObjectType, componentOf: /ua:Objects }
instances:
- expand:
over: { file: tanks.csv }
index: n # The mistake: the position of a row is not stable.
use: Tank

tanks.csv:

id
T1

The message:

TPL-W002 warning instances[0]: `index` in a block that reads a table: moving or inserting a row changes every value after it; put the value in a column instead