Debugging Strategies

Add Intermediate Variables

Break complex expressions into steps and write intermediate values to Data for inspection:

# Hard to debug
Data.result = SortByField(WhereByField(Data.items, "active", "==", true), "price", "desc")

# Easy to debug
var active = WhereByField(Data.items, "active", "==", true)
Data.debugActive = active
var sorted = SortByField(active, "price", "desc")
Data.debugSorted = sorted
Data.result = sorted

Inspect Types and Values

Write a debug object to Data to examine runtime state:

Data.debug = {
    "inputType": TypeOf(Data.input),
    "inputValue": Data.input,
    "isNull": Data.input is null,
    "length": Data.input is array ? Length(Data.input) : "N/A"
}

Use Type Guards Liberally

Guard against mixed types with is checks and continue:

foreach item in Data.items do
    if item is not object then
        continue
    end
    if item.price is not number then
        continue
    end
    # Safe to process
    total += item.price
end

Test with Minimal Data First

Start with the simplest possible input:

{"items": [{"id": 1, "price": 10}]}

Then add edge cases incrementally:

{"items": [{"id": 1, "price": 10}, {"id": 2, "price": null}, {"id": 3}]}

Back to top

Copyright © Mesch Systems 2025-2026. All rights reserved.