{"record":{"id":"d933dae235140fb7","repo":"lobehub/lobehub","slug":"path-series-must-be-a-non-empty-array","errorCode":null,"errorMessage":"${path}.series must be a non-empty array","messagePattern":"(.+?)\\.series must be a non-empty array","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"apps/cli/src/commands/verifyHelpers.ts","lineNumber":198,"sourceCode":") => {\n  if (encoding[key] === undefined) return;\n  visualizationField(encoding, key, fieldKeys, path);\n};\n\nconst optionalVisualizationString = (value: Record<string, unknown>, key: string, path: string) => {\n  if (value[key] !== undefined && !firstString(value[key])) {\n    throw new Error(`${path}.${key} must be a non-empty string`);\n  }\n};\n\nconst visualizationSeries = (\n  encoding: Record<string, unknown>,\n  fieldKeys: Set<string>,\n  path: string,\n  options?: { styles?: boolean },\n) => {\n  if (!Array.isArray(encoding.series) || encoding.series.length === 0) {\n    throw new Error(`${path}.series must be a non-empty array`);\n  }\n  encoding.series.forEach((rawSeries, seriesIndex) => {\n    const series = objectValue(rawSeries);\n    const seriesPath = `${path}.series[${seriesIndex}]`;\n    if (!series) throw new Error(`${seriesPath} must be an object`);\n    visualizationField(series, 'field', fieldKeys, seriesPath);\n    if (series.label !== undefined && !firstString(series.label)) {\n      throw new Error(`${seriesPath}.label must be a non-empty string`);\n    }\n    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};","sourceCodeStart":180,"sourceCodeEnd":216,"githubUrl":"https://github.com/lobehub/lobehub/blob/10f24d7ade75139093a9373b364f6bc91f3cd7db/apps/cli/src/commands/verifyHelpers.ts#L180-L216","documentation":"Thrown by `visualizationSeries` during verify visualization validation when a chart type that requires a `series` array (bar-chart, line-chart) has an `encoding.series` that is either not an array or is an empty array. At least one series is required so the chart has data to plot. `${path}` is `visualizations[i].encoding`.","triggerScenarios":"Omitting `series` entirely for a bar/line chart; setting `series: {}` or `series: \"a\"`; providing `series: []` with no entries; a templating loop produced zero series because its source list was empty.","commonSituations":"Building a manifest from a dataset that had no series dimension; a conditional that filtered out all series; copy-pasting a scatter-plot encoding (which has no series) into a bar-chart block.","solutions":["Add at least one series entry: `{field: '<datasetField>', label?: '...'}`.","Ensure each series references a real declared dataset field.","If you intended a chart without series, switch the `type` to one that does not require it (e.g. `scatter-plot`, `metric-comparison`).","For templated manifests, fail fast when the series source list is empty rather than emitting `series: []`."],"exampleFix":"// before\n{ \"type\": \"bar-chart\", \"encoding\": { \"category\": \"model\", \"series\": [] } }\n// -> visualizations[0].encoding.series must be a non-empty array\n\n// after\n{ \"type\": \"bar-chart\", \"encoding\": {\n    \"category\": \"model\",\n    \"series\": [ { \"field\": \"scores\", \"label\": \"Score\" } ]\n}}","handlingStrategy":"validation","validationCode":"function assertSeries(encoding: Record<string, unknown>, path: string) {\n  if (!Array.isArray(encoding.series) || encoding.series.length === 0) {\n    throw new Error(`${path}.series must be a non-empty array`);\n  }\n}","typeGuard":"const hasNonEmptySeries = (v: unknown): v is { series: unknown[] } =>\n  !!v && typeof v === 'object' && Array.isArray((v as any).series) && (v as any).series.length > 0;","tryCatchPattern":null,"preventionTips":["For bar/line charts, always supply at least one series entry.","If your data has no series dimension, switch to a chart type that doesn't need one.","In templating, fail fast when the series source list is empty.","Validate the manifest with a schema keyed on chart type."],"tags":["cli","verify","visualization","validation","series"],"backgroundTag":null,"analyzedSha":"10f24d7ade75139093a9373b364f6bc91f3cd7db","analyzedAt":"2026-08-12T11:43:19.543Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}