{"record":{"id":"350570840597b1e7","repo":"apache/superset","slug":"this-version-does-not-record-a-visualization-type","errorCode":null,"errorMessage":"This version does not record a visualization type and dataset, so a new chart cannot be built from it","messagePattern":"This version does not record a visualization type and dataset, so a new chart cannot be built from it","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"superset-frontend/src/features/versionHistory/api.ts","lineNumber":128,"sourceCode":"  });\n  return json as { message: string };\n}\n\n/** Creates a new chart from a version snapshot; returns the new chart id. */\nexport async function createChartFromSnapshot(\n  snapshot: ChartVersionSnapshot,\n  name: string,\n): Promise<number> {\n  // The chart POST requires all three; the version table allows null for each\n  // (a delete version carries nulls throughout). Fail here with something the\n  // caller can turn into a toast rather than sending a payload the API will\n  // reject with a validation error the user cannot act on.\n  if (\n    snapshot.viz_type == null ||\n    snapshot.datasource_id == null ||\n    snapshot.datasource_type == null\n  ) {\n    throw new Error(\n      'This version does not record a visualization type and dataset, so a new chart cannot be built from it',\n    );\n  }\n  const { json } = await SupersetClient.post({\n    endpoint: '/api/v1/chart/',\n    jsonPayload: {\n      slice_name: name,\n      viz_type: snapshot.viz_type,\n      datasource_id: snapshot.datasource_id,\n      datasource_type: snapshot.datasource_type,\n      ...(snapshot.params != null && { params: snapshot.params }),\n      ...(snapshot.query_context != null && {\n        query_context: snapshot.query_context,\n      }),\n      ...(snapshot.description != null && {\n        description: snapshot.description,\n      }),\n      ...(snapshot.cache_timeout != null && {","sourceCodeStart":110,"sourceCodeEnd":146,"githubUrl":"https://github.com/apache/superset/blob/f4587218dd19d046c3e4d00063e7d27f8a2ed354/superset-frontend/src/features/versionHistory/api.ts#L110-L146","documentation":"Thrown by the version-history feature when trying to create a new chart from a stored chart version whose viz_type, datasource_id, or datasource_type is null. The version table permits nulls (a 'delete' version records nulls throughout), but the chart POST endpoint requires all three; the client fails fast with an actionable message instead of letting the API return an opaque validation error.","triggerScenarios":"Selecting a version in the version-history panel and choosing 'create chart from this version' where the version is a deletion snapshot, or an older version row written before viz/datasource tracking was added.","commonSituations":"Users clicking a 'deleted' entry in version history; restoring from versions created before the snapshot fields existed (upgrade/migration); versions whose chart was deleted and only the tombstone remains.","solutions":["Pick a non-delete version (one that records a visualization type and dataset) from the history list.","If the chart was deleted, restore the chart first so real versions with metadata exist, then create from a version.","As a developer, filter version entries with null viz_type/datasource out of the 'create chart' UI before the action is offered."],"exampleFix":"// before\nconst id = await createChartFromVersion(snapshot, name);\n\n// after\nif (snapshot.viz_type == null || snapshot.datasource_id == null || snapshot.datasource_type == null) {\n  disableCreateFromVersion(snapshot.id);\n} else {\n  const id = await createChartFromVersion(snapshot, name);\n}","handlingStrategy":"validation","validationCode":"const canCreateFromVersion = (s: ChartVersionSnapshot): boolean =>\n  s.viz_type != null && s.datasource_id != null && s.datasource_type != null;\nif (!canCreateFromVersion(snapshot)) {\n  disableCreateAction(snapshot);\n}","typeGuard":"const isCreatableSnapshot = (\n  s: ChartVersionSnapshot,\n): s is ChartVersionSnapshot & { viz_type: string; datasource_id: number; datasource_type: string } =>\n  s.viz_type != null && s.datasource_id != null && s.datasource_type != null;","tryCatchPattern":"try { await createChartFromVersion(snapshot, name); } catch (e) { if (e.message.includes('does not record a visualization type')) showToast('Pick a non-delete version'); else throw e; }","preventionTips":["Hide the create-chart action on tombstone (null-metadata) versions","Restore deleted charts before creating from their versions"],"tags":["version-history","chart","validation","fail-fast"],"backgroundTag":null,"analyzedSha":"f4587218dd19d046c3e4d00063e7d27f8a2ed354","analyzedAt":"2026-08-14T22:39:27.425Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}