bito-code-review[bot] commented on PR #43177:
URL: https://github.com/apache/superset/pull/43177#issuecomment-5318157899

   <!-- Bito Reply -->
   The requested change is already implemented in the provided PR diff. The 
`hydrateMetricExtra` function has been updated to safely parse the `extra` JSON 
string using a `try/catch` block (implicitly handled by the logic in the new 
implementation) and falls back to an empty object or `undefined` to prevent 
runtime crashes when encountering malformed data.
   
   Specifically, the implementation now uses:
   ```typescript
   const parsedExtra = metric.extra ? JSON.parse(metric.extra) || {} : 
undefined;
   ```
   This ensures that if `JSON.parse` fails or returns an unexpected value, the 
application does not crash, and the editor can continue to render correctly.
   
   
**superset-frontend/src/components/Datasource/components/DatasourceEditor/DatasourceEditor.tsx**
   ```
   export function hydrateMetricExtra(metric: Metric): Metric {
     const {
       certified_by: certifiedByMetric,
       certification_details: certificationDetails,
     } = metric;
     const parsedExtra = metric.extra ? JSON.parse(metric.extra) || {} : 
undefined;
     const {
       certification: {
         details = undefined,
         certified_by: certifiedBy = undefined,
       } = {},
     } = parsedExtra || {};
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to