A platform for community discussion. Free, open, simple.
FIX: Auto-rendered charts crash on NULL label values (#39940)
discourse-patch-triage[bot]4851489e84d4
diff --git a/plugins/discourse-data-explorer/assets/javascripts/discourse/components/query-result.gjs b/plugins/discourse-data-explorer/assets/javascripts/discourse/components/query-result.gjsindex aa7f655127c..2d1208bc1cb 100644--- a/plugins/discourse-data-explorer/assets/javascripts/discourse/components/query-result.gjs+++ b/plugins/discourse-data-explorer/assets/javascripts/discourse/components/query-result.gjs@@ -337,7 +337,7 @@ export default class QueryResult extends Component {}_cutChartLabel(label) {- const labelString = label.toString();+ const labelString = String(label ?? "NULL");if (labelString.length > 25) {return `${labelString.substring(0, 25)}...`;} else {diff --git a/plugins/discourse-data-explorer/test/javascripts/integration/components/query-result-test.gjs b/plugins/discourse-data-explorer/test/javascripts/integration/components/query-result-test.gjsindex fd02b90b094..fb94046fb3a 100644--- a/plugins/discourse-data-explorer/test/javascripts/integration/components/query-result-test.gjs+++ b/plugins/discourse-data-explorer/test/javascripts/integration/components/query-result-test.gjs@@ -252,6 +252,22 @@ module("Integration | Component | query-result | chart", function (hooks) {assert.dom("canvas").exists("renders a chart canvas");});+ test("renders charts with null label values", async function (assert) {+ const content = {+ colrender: [],+ result_count: 2,+ columns: ["user_name", "like_count"],+ rows: [+ [null, 10],+ ["user2", 20],+ ],+ };++ await render(<template><QueryResult @content={{content}} /></template>);++ assert.dom("canvas").exists("renders a chart canvas");+ });+test("renders a multi-series chart", async function (assert) {const content = {colrender: [],