Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions mdl-examples/bug-tests/chart-series-customseriesoptions-json.mdl
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
-- ============================================================================
-- Bug: chart series customSeriesOptions emitted as " " → runtime JSON.parse error
-- ============================================================================
--
-- Symptom:
-- A ColumnChart (or any chart with a `series`/`line` object-list) passed
-- `mx check` (0 errors) but failed to RENDER at runtime with a client-side
-- `JSON.parse('Unexpected end of JSON input')` in the chart render path. A Pie
-- chart over the same data (widget-level datasource, no series object-list)
-- rendered fine.
--
-- Root cause:
-- The object-list-item builder emitted an unset String property as a single
-- space " " (not ""). The chart client feeds customSeriesOptions /
-- customLayout / customConfigurations straight to JSON.parse with an empty-guard
-- `value !== "" ? value : "{}"`. A lone space passes that guard, so the client
-- runs `JSON.parse(" ")` and throws. (mx check does not execute the client, so
-- it stayed green.) The top-level string path already emitted "".
--
-- Fix:
-- createDefaultWidgetValue (object-list-item path) leaves an unset String empty,
-- matching Studio Pro and the top-level path, so the client's empty-guard turns
-- it into "{}".
--
-- Verify:
-- mxcli exec mdl-examples/bug-tests/chart-series-customseriesoptions-json.mdl -p app.mpr
-- # the series' customSeriesOptions is now "" (was " "); the ColumnChart renders.
-- mx check app.mpr # still 0 errors
-- Requires: Charts .mpk installed in the project's widgets/.
-- ============================================================================

create module ColJSON;
/
create entity ColJSON.Sales ( Region: String, Total: Decimal );
/
create or replace page ColJSON.Home ( layout: Atlas_Core.Atlas_Default ) {
pluggablewidget 'com.mendix.widget.web.columnchart.ColumnChart' col1 {
series s ( dataSet: static, staticDataSource: database from ColJSON.Sales,
staticXAttribute: Region, staticYAttribute: Total, staticName: 'Revenue' )
}
}
11 changes: 8 additions & 3 deletions mdl/backend/widgetobj/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -1291,9 +1291,14 @@ func createDefaultWidgetValue(entry pages.PropertyTypeIDEntry) bson.D {
textTemplate = createDefaultClientTemplateBSON(primitiveVal)
}
case "String":
if primitiveVal == "" {
primitiveVal = " "
}
// Leave an unset String property empty (its schema default, "") — do NOT
// manufacture a single space. Studio Pro stores "" here, and some widgets
// (chart series `customSeriesOptions`, `customLayout`, `customConfigurations`)
// feed the value straight to a client-side JSON.parse whose empty-guard is
// `value !== "" ? value : "{}"`; a lone space passes that guard and makes
// the widget throw `JSON.parse(" ")` → "Unexpected end of JSON input" at
// render time (object-list-item path only; the top-level path already
// leaves it empty).
}

return bson.D{
Expand Down
Loading