{"record":{"id":"3b18dd74d727ef69","repo":"lobehub/lobehub","slug":"path-is-required-for-string-view-type","errorCode":null,"errorMessage":"${path} is required for ${String(view.type)}","messagePattern":"(.+?) is required for (.+?)","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"apps/cli/src/commands/verifyHelpers.ts","lineNumber":226,"sourceCode":"    if (\n      options?.styles &&\n      series.style !== undefined &&\n      !['accent', 'muted', 'primary'].includes(String(series.style))\n    ) {\n      throw new Error(`${seriesPath}.style is invalid`);\n    }\n  });\n};\n\nconst validateVisualizationEncoding = (\n  view: Record<string, unknown>,\n  fieldKeys: Set<string>,\n  index: number,\n) => {\n  const path = `visualizations[${index}].encoding`;\n  if (view.type === 'table' && view.encoding === undefined) return;\n  const encoding = objectValue(view.encoding);\n  if (!encoding) throw new Error(`${path} is required for ${String(view.type)}`);\n\n  switch (view.type) {\n    case 'bar-chart': {\n      visualizationField(encoding, 'category', fieldKeys, path);\n      visualizationSeries(encoding, fieldKeys, path);\n      optionalVisualizationString(encoding, 'valueLabel', path);\n      break;\n    }\n    case 'heatmap': {\n      visualizationField(encoding, 'x', fieldKeys, path);\n      visualizationField(encoding, 'y', fieldKeys, path);\n      visualizationField(encoding, 'value', fieldKeys, path);\n      break;\n    }\n    case 'line-chart': {\n      visualizationField(encoding, 'x', fieldKeys, path);\n      visualizationSeries(encoding, fieldKeys, path, { styles: true });\n      optionalVisualizationString(encoding, 'xLabel', path);","sourceCodeStart":208,"sourceCodeEnd":244,"githubUrl":"https://github.com/lobehub/lobehub/blob/10f24d7ade75139093a9373b364f6bc91f3cd7db/apps/cli/src/commands/verifyHelpers.ts#L208-L244","documentation":"Thrown by `validateVisualizationEncoding` during verify visualization validation when a non-`table` view is missing an `encoding` object (or its value is not an object). Every chart type except `table` requires an `encoding`. `${path}` is `visualizations[i].encoding`, and `${String(view.type)}` names the chart type so the message reads e.g. '... is required for bar-chart'.","triggerScenarios":"Declaring `{type: 'bar-chart'}` with no `encoding`; setting `encoding: null`; `encoding: \"\"`; copy-pasting a `table` view (which may omit encoding) but changing the type to a chart without adding encoding.","commonSituations":"Starting from the table template (the only type that allows missing encoding) and switching the type; manifests assembled field-by-field where encoding was forgotten; a refactor that moved encoding under a wrong key.","solutions":["Add an `encoding` object with the fields required for that chart type (see the per-type validators).","Confirm the `type` is what you intended — if you want no encoding, use `type: 'table'`.","Use the chart-type reference: bar-chart needs category+series, heatmap needs x/y/value, scatter-plot needs x/y, metric-comparison needs label/before/after, line-chart needs x+series."],"exampleFix":"// before\n{ \"type\": \"heatmap\" }\n// -> visualizations[0].encoding is required for heatmap\n\n// after\n{ \"type\": \"heatmap\", \"encoding\": { \"x\": \"model\", \"y\": \"task\", \"value\": \"score\" } }","handlingStrategy":"validation","validationCode":"function assertEncodingForType(view: Record<string, unknown>, path: string) {\n  if (view.type === 'table' && view.encoding === undefined) return;\n  if (!view.encoding || typeof view.encoding !== 'object' || Array.isArray(view.encoding)) {\n    throw new Error(`${path} is required for ${String(view.type)}`);\n  }\n}","typeGuard":"const isEncodingObject = (v: unknown): v is Record<string, unknown> =>\n  !!v && typeof v === 'object' && !Array.isArray(v);","tryCatchPattern":null,"preventionTips":["Always pair a chart `type` with the encoding fields it requires.","Start from a per-type template rather than a generic stub.","Validate the manifest with a schema discriminated on `type`.","If you genuinely want no encoding, use `type: 'table'`."],"tags":["cli","verify","visualization","validation","encoding"],"backgroundTag":null,"analyzedSha":"10f24d7ade75139093a9373b364f6bc91f3cd7db","analyzedAt":"2026-08-12T11:43:19.543Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}