Error Codes
Complete reference for all Constela validation and runtime errors
Overview
Constela provides descriptive error codes to help you quickly identify and fix issues in your programs. Each error code follows the format CATEGORY_SPECIFIC.
SCHEMA_INVALID
When it occurs: The program structure does not match the expected schema.
Common causes:
- Missing required fields (
version,state,actions,view) - Invalid field types
- Malformed JSON
How to fix:
// Invalid - missing version
{
"state": { ... },
"view": { ... }
}
// Valid
{
"version": "1.0",
"state": { ... },
"actions": [],
"view": { ... }
}UNDEFINED_STATE
When it occurs: A state expression references a state field that does not exist.
Common causes:
- Typo in state name
- Forgot to declare the state field
- State name mismatch between declaration and usage
How to fix:
// Error: UNDEFINED_STATE for "counter"
{
"state": {
"count": { "type": "number", "initial": 0 }
},
"view": {
"kind": "text",
"value": { "expr": "state", "name": "counter" } // Wrong name!
}
}
// Fixed: Use correct state name
{
"value": { "expr": "state", "name": "count" }
}UNDEFINED_ACTION
When it occurs: An event handler references an action that does not exist.
Common causes:
- Typo in action name
- Action not defined in
actionsarray - Case sensitivity issues
How to fix:
// Error: UNDEFINED_ACTION for "Increment"
{
"actions": [
{ "name": "increment", "steps": [...] }
],
"view": {
"kind": "element",
"tag": "button",
"props": {
"onClick": { "event": "click", "action": "Increment" } // Case mismatch!
}
}
}
// Fixed: Match exact action name
{
"props": {
"onClick": { "event": "click", "action": "increment" }
}
}VAR_UNDEFINED
When it occurs: A variable expression references a variable that is not in scope.
Common causes:
- Using
varexpression outside of aneachloop or component - Typo in variable name
- Variable name mismatch with
asdeclaration
How to fix:
// Error: VAR_UNDEFINED for "item"
{
"kind": "each",
"items": { "expr": "state", "name": "items" },
"as": "todo", // Declared as "todo"
"body": {
"kind": "text",
"value": { "expr": "var", "name": "item" } // Wrong name!
}
}
// Fixed: Use correct variable name
{
"value": { "expr": "var", "name": "todo" }
}DUPLICATE_ACTION
When it occurs: Two or more actions share the same name.
Common causes:
- Copy-paste error
- Forgot to rename duplicated action
How to fix:
// Error: DUPLICATE_ACTION for "handleClick"
{
"actions": [
{ "name": "handleClick", "steps": [...] },
{ "name": "handleClick", "steps": [...] } // Duplicate!
]
}
// Fixed: Use unique names
{
"actions": [
{ "name": "handleClickPrimary", "steps": [...] },
{ "name": "handleClickSecondary", "steps": [...] }
]
}UNSUPPORTED_VERSION
When it occurs: The specified DSL version is not supported.
Common causes:
- Using a version that does not exist
- Typo in version string
How to fix:
// Error: UNSUPPORTED_VERSION for "2.0"
{
"version": "2.0",
...
}
// Fixed: Use supported version
{
"version": "1.0",
...
}Note
Currently, only version "1.0" is supported.
COMPONENT_NOT_FOUND
When it occurs: A component node references a component that is not defined.
Common causes:
- Component not defined in
componentsobject - Typo in component name
- Case sensitivity issues
How to fix:
// Error: COMPONENT_NOT_FOUND for "button"
{
"components": {
"Button": { ... }
},
"view": {
"kind": "component",
"name": "button" // Case mismatch!
}
}
// Fixed: Match exact component name
{
"kind": "component",
"name": "Button"
}COMPONENT_PROP_MISSING
When it occurs: A required component prop is not provided.
Common causes:
- Forgot to pass a required prop
- Typo in prop name
How to fix:
// Error: COMPONENT_PROP_MISSING for "label"
{
"components": {
"Button": {
"props": {
"label": { "type": "string" } // Required prop
},
"view": { ... }
}
},
"view": {
"kind": "component",
"name": "Button",
"props": {} // Missing label!
}
}
// Fixed: Provide required prop
{
"kind": "component",
"name": "Button",
"props": {
"label": { "expr": "lit", "value": "Click me" }
}
}COMPONENT_CYCLE
When it occurs: A component directly or indirectly references itself, creating an infinite loop.
Common causes:
- Component A uses Component B, which uses Component A
- Component using itself in its own view
How to fix:
// Error: COMPONENT_CYCLE detected
{
"components": {
"Card": {
"props": { "title": { "type": "string" } },
"view": {
"kind": "component",
"name": "Card", // Self-reference!
"props": { ... }
}
}
}
}
// Fixed: Remove circular reference
{
"components": {
"Card": {
"props": { "title": { "type": "string" } },
"view": {
"kind": "element",
"tag": "div",
"children": [...]
}
}
}
}COMPONENT_PROP_TYPE
When it occurs: A prop value does not match the expected type.
Common causes:
- Passing wrong type (e.g., number instead of string)
- Expression evaluates to wrong type
How to fix:
// Error: COMPONENT_PROP_TYPE for "count" (expected number)
{
"components": {
"Counter": {
"props": {
"count": { "type": "number" }
},
"view": { ... }
}
},
"view": {
"kind": "component",
"name": "Counter",
"props": {
"count": { "expr": "lit", "value": "42" } // String, not number!
}
}
}
// Fixed: Use correct type
{
"props": {
"count": { "expr": "lit", "value": 42 }
}
}PARAM_UNDEFINED
When it occurs: A param expression references a parameter that is not available.
Common causes:
- Using
paramexpression outside of action steps - Typo in parameter name
- Accessing wrong parameter context
How to fix:
// Error: PARAM_UNDEFINED for "data"
{
"do": "set",
"target": "result",
"value": { "expr": "param", "name": "data" } // Wrong param name!
}
// Fixed: Use correct parameter name
// In onSuccess, use "result" for response data
{
"do": "set",
"target": "result",
"value": { "expr": "param", "name": "result" }
}Tip
In fetch onSuccess handlers, use result to access the response data. In onError handlers, use error to access error information.
UNDEFINED_STYLE
When it occurs: A style expression references a style preset that does not exist.
Common causes:
- Typo in style name
- Style not defined in
stylesobject - Case sensitivity issues
How to fix:
// Error: UNDEFINED_STYLE for "buttons"
{
"styles": {
"button": { ... }
},
"view": {
"props": {
"className": { "expr": "style", "name": "buttons" } // Typo!
}
}
}
// Fixed: Use correct style name
{
"props": {
"className": { "expr": "style", "name": "button" }
}
}UNDEFINED_VARIANT
When it occurs: A style expression specifies a variant key or value that does not exist in the style preset.
Common causes:
- Typo in variant key or value
- Using a variant not defined in the style
- Case sensitivity issues
How to fix:
// Error: UNDEFINED_VARIANT for "xlarge" in style "button"
{
"styles": {
"button": {
"variants": {
"size": { "sm": "...", "md": "...", "lg": "..." }
}
}
},
"view": {
"props": {
"className": {
"expr": "style",
"name": "button",
"variants": { "size": { "expr": "lit", "value": "xlarge" } }
}
}
}
}
// Fixed: Use valid variant value
{
"variants": { "size": { "expr": "lit", "value": "lg" } }
}Debugging Tips
- Read the full error message: Error messages include the location and context of the issue.
- Check spelling: Most errors are caused by typos in names.
- Verify declarations: Ensure all state, actions, and components are properly declared before use.
- Use a JSON validator: Make sure your JSON is valid before running through Constela.
- Start simple: Build your UI incrementally, testing after each change.