⚠️ Validation Errors

Troubleshooting SHACL and DSL validation failures.


DSL Validation Errors

SyntaxError

Cause: Grammar/parsing issues

1
2
SyntaxError at line 15, col 10:
  Expected 'as' but found 'in'

Fix: Check DSL syntax against language reference


TypeError

Cause: Type mismatch

1
2
3
TypeError at line 20:
  Cannot compare String to Number
  Expression: entity.name > 100

Fix: Ensure operand types are compatible


UnitError.MismatchedDimension

Cause: Adding/comparing incompatible units

1
2
3
UnitError.MismatchedDimension at line 25:
  Cannot add Currency to Mass
  Expression: payment.quantity + steel.quantity

Fix: Use as "unit" to convert or separate calculations

# Wrong
total = payment.quantity + steel.quantity

# Correct - separate by dimension
payment_total = sum(f in flows where f.resource = "Money": f.quantity as "USD")
steel_total = sum(f in flows where f.resource = "Steel": f.quantity as "kg")

ScopeError.UnknownIdentifier

Cause: Reference to undeclared entity/resource

1
2
ScopeError.UnknownIdentifier at line 30:
  Unknown entity "Warehouse.B"

Fix: Declare the entity before referencing

Entity "Warehouse.B" in logistics  # Add this
Flow "Delivery" from "Plant.A" to "Warehouse.B" quantity 100 "kg"

SHACL Validation Errors

sh:minCount Violation

Cause: Missing required property

1
2
3
4
5
6
{
  "node": "http://example.org/entity/123",
  "constraint": "sh:minCount",
  "path": "rdfs:label",
  "message": "Node must have at least 1 value for rdfs:label"
}

Fix: Add the required property

1
2
3
INSERT DATA {
  <http://example.org/entity/123> rdfs:label "Entity 123" .
}

sh:datatype Violation

Cause: Wrong value type

1
2
3
4
5
6
{
  "node": "http://example.org/flow/456",
  "path": "sea:quantity",
  "constraint": "sh:datatype xsd:decimal",
  "message": "Value 'one hundred' is not a valid xsd:decimal"
}

Fix: Correct the value type

1
2
3
DELETE { <http://example.org/flow/456> sea:quantity "one hundred" }
INSERT { <http://example.org/flow/456> sea:quantity 100.0 }
WHERE { <http://example.org/flow/456> sea:quantity "one hundred" }

sh:class Violation

Cause: Reference to wrong type

1
2
3
4
5
6
{
  "node": "http://example.org/flow/789",
  "path": "sea:from",
  "constraint": "sh:class sea:Entity",
  "message": "Value must be of type sea:Entity"
}

Fix: Ensure referenced node has correct type

1
2
3
4
5
6
7
8
9
# Check the referenced node
SELECT ?type WHERE {
  <http://example.org/referenced-node> a ?type .
}

# Add correct type if missing
INSERT DATA {
  <http://example.org/referenced-node> a sea:Entity .
}

Custom SPARQL Violation

Cause: Business rule failure

1
2
3
4
5
{
  "node": "http://example.org/vendor/x",
  "constraint": "VendorLimitShape",
  "message": "Vendor payment limit exceeded: $7500 > $5000"
}

Fix: Address the business rule (reduce payments, increase limit, etc.)


Validation Commands

1
2
3
4
5
6
7
8
# DSL validation
sea validate models/ --type-check --unit-check --verbose

# SHACL validation
sea graph validate --shapes shapes/ --verbose

# Full pipeline
sea validate --all models/