{"record":{"id":"237948eceb59952b","repo":"apache/superset","slug":"please-call-with-an-object-example-stringify-my","errorCode":null,"errorMessage":"Please call with an object. Example: `stringify myObj`","messagePattern":"Please call with an object\\. Example: `stringify myObj`","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"superset-frontend/plugins/plugin-chart-handlebars/src/components/Handlebars/HandlebarsViewer.tsx","lineNumber":90,"sourceCode":"        htmlSanitization={htmlSanitization}\n        htmlSchemaOverrides={htmlSchemaOverrides}\n      />\n    );\n  }\n  return <p>{t('Loading...')}</p>;\n};\n\n//  usage: {{ dateFormat my_date format=\"MMMM YYYY\" }}\nHandlebars.registerHelper('dateFormat', function (context, block) {\n  const f = block.hash.format || 'YYYY-MM-DD';\n  return dayjs(context).format(f);\n});\n\n// usage: {{  }}\nHandlebars.registerHelper('stringify', (obj: any, obj2: any) => {\n  // calling without an argument\n  if (obj2 === undefined)\n    throw new Error('Please call with an object. Example: `stringify myObj`');\n  return isPlainObject(obj) ? JSON.stringify(obj) : String(obj);\n});\n\nHandlebars.registerHelper(\n  'formatNumber',\n  function (number: any, locale = 'en-US') {\n    if (typeof number !== 'number') {\n      return number;\n    }\n    return number.toLocaleString(locale);\n  },\n);\n\n// usage: {{parseJson jsonString}}\nHandlebars.registerHelper('parseJson', (jsonString: string) => {\n  try {\n    return JSON.parse(jsonString);\n  } catch (error) {","sourceCodeStart":72,"sourceCodeEnd":108,"githubUrl":"https://github.com/apache/superset/blob/f4587218dd19d046c3e4d00063e7d27f8a2ed354/superset-frontend/plugins/plugin-chart-handlebars/src/components/Handlebars/HandlebarsViewer.tsx#L72-L108","documentation":"A Handlebars helper registered by the Handlebars (markdown-templated) chart plugin. The stringify helper throws when it is invoked in a template without a usable argument (the second positional parameter is undefined), telling the template author to call it as {{stringify myObj}} to pretty-print an object.","triggerScenarios":"A Handlebars template used by the chart contains {{stringify}} with no argument, or passes undefined (e.g. {{stringify missingField}} where the field is absent from the row).","commonSituations":"Templates authored against sample data where the field existed, then pointed at data missing that column; typos in field names inside the template; templates copied from just-handlebars-factories examples.","solutions":["Fix the template: call {{stringify myObj}} with an actual object field present in the query result.","Guard in the template: {{#if myObj}}{{stringify myObj}}{{/if}}.","Verify the column names in the template match the dataset columns returned by the chart query.","Render the chart with sample rows in Explore to confirm the field exists before publishing."],"exampleFix":"{{! before }}\n{{stringify}}\n\n{{! after }}\n{{#if row.payload}}\n  {{stringify row.payload}}\n{{/if}}","handlingStrategy":"type-guard","validationCode":"{{! inside the Handlebars template }}\n{{#if myObj}}\n  {{stringify myObj}}\n{{/if}}","typeGuard":"{{! custom guard helper or inline check }}\n{{#if (isPlainObject myObj)}}\n  {{stringify myObj}}\n{{else}}\n  <span class=\"muted\">n/a</span>\n{{/if}}","tryCatchPattern":"try {\n  const html = Handlebars.compile(templateString)(data);\n} catch (e) {\n  if (e instanceof Error && e.message.includes('stringify')) {\n    setTemplateError(t('Template calls stringify without an object; check field names'));\n    return;\n  }\n  throw e;\n}","preventionTips":["Test templates against representative rows (including missing fields) before publishing the chart.","Prefer {{#if}} guards around helpers that require arguments.","Keep a lint step for templates that flags helpers invoked with zero arguments."],"tags":["handlebars","template","visualization","chart-plugin"],"backgroundTag":null,"analyzedSha":"f4587218dd19d046c3e4d00063e7d27f8a2ed354","analyzedAt":"2026-08-14T22:39:27.425Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}