๐ Better syntax validation for Canvas Dashboard
๐ฅ Why this feature?โ
Some of our customers were struggling with cryptic field reference errors that only showed up when trying to publish dashboards. No clear error messages, no way to navigate to problems, and broken references went undetected when fields were renamed. This was creating a poor developer experience and blocking teams from scaling their analytics.
๐ก How it worksโ
- Real-time validation: Field reference errors now show up immediately with red underlines as you type
- Click-to-navigate: Click on errors to jump directly to the problematic code
- New
r()
syntax: User(users.id)
instead ofref('users', 'id')
Before vs Afterโ
โ Before (Old Syntax)
// Old syntax - prone to typos, no IDE support
VizBlock {
label: 'Revenue by Category'
viz: PieChart {
dataset: 'ecommerce'
legend: ref('products', 'category') // No validation
series {
field {
ref: ref('orders', 'revenue') // String-based, error-prone
aggregation: 'sum'
}
}
}
}
// ๐ฐ Common issues:
// - Typo: ref('product', 'category') โ No error until runtime
// - Renamed field: orders.revenue โ orders.total_revenue โ Broken reference
// - No autocomplete or navigation support
โ After (New Syntax)
// New syntax - validated, IDE-friendly
VizBlock {
label: 'Revenue by Category'
viz: PieChart {
dataset: 'ecommerce'
legend: r(products.category) // Real-time validation
series {
field {
ref: r(orders.revenue) // Click to navigate to definition
aggregation: 'sum'
}
}
}
}
// ๐ Benefits:
// - Typo: r(product.category) โ Immediate red underline
// - Renamed field: Automatic detection of broken references
// - Full IDE support: autocomplete, go-to-definition, find usages
Note
This applies everywhere we use field references - not just dashboards but also Pre-aggregates.
๐ Migration to new syntaxโ
We don't support mass conversion yet, but the transition is seamless:
- New dashboards automatically use the new
r(model_name.field_name)
syntax - Existing dashboards convert to new syntax whenever you edit and save a widget
- Old syntax still works - no breaking changes.