{"record":{"id":"3ab61e71cc374b36","repo":"actualbudget/actual","slug":"unsupported-summary-type","errorCode":null,"errorMessage":"Unsupported summary type","messagePattern":"Unsupported summary type","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/desktop-client/src/components/reports/spreadsheets/summary-spreadsheet.ts","lineNumber":182,"sourceCode":"          ...calculatePerYear(data.data, startDay, endDay),\n        });\n        break;\n      }\n\n      case 'percentage':\n        setData({\n          ...dateRanges,\n          ...(await calculatePercentage(\n            data.data,\n            summaryContent,\n            startDay,\n            endDay,\n          )),\n        });\n        break;\n\n      default:\n        throw new Error(`Unsupported summary type`);\n    }\n  };\n}\n\nfunction calculatePerMonth(\n  data: Array<{\n    date: string;\n    amount: number;\n    count: number;\n  }>,\n  months: Date[],\n) {\n  if (!data.length || !months.length) {\n    return { total: 0, dividend: 0, divisor: 0 };\n  }\n\n  const monthlyData = data.reduce(\n    (acc, day) => {","sourceCodeStart":164,"sourceCodeEnd":200,"githubUrl":"https://github.com/actualbudget/actual/blob/d4334cb6e6123f4d3bcea1ad6166608884c7e658/packages/desktop-client/src/components/reports/spreadsheets/summary-spreadsheet.ts#L164-L200","documentation":"summarySpreadsheet switches on summaryContent.type to compute the summary value (sum, avgPerTransact, avgPerMonth, avgPerYear, percentage). If the type matches none of the known cases, the default branch throws 'Unsupported summary type'. This guards against stale or invalid SummaryContent configs reaching the spreadsheet builder.","triggerScenarios":"Passing a summaryContent object whose type is not one of 'sum' | 'avgPerTransact' | 'avgPerMonth' | 'avgPerYear' | 'percentage' — e.g. a typo like 'avgpermonth', an old serialized config from a previous schema, or a new type added in the UI before the spreadsheet supports it.","commonSituations":"Persisted dashboard/report JSON created by a newer or older version of the app being loaded by a version without that summary type; plugin or API code constructing SummaryContent by hand with an invalid type; a rename of the type union not migrated in stored configs.","solutions":["Inspect summaryContent.type at the call site and use one of the supported values: sum, avgPerTransact, avgPerMonth, avgPerYear, percentage","If the config is persisted, migrate or re-create the summary widget so it stores a valid type","Narrow the input with the SummaryContent type union and let TypeScript catch invalid types at compile time","Wrap in try/catch and render a fallback message for unknown summary types"],"exampleFix":"// before\nsummarySpreadsheet(start, end, conditions, op, { type: 'average' } as SummaryContent, locale);\n// after\nsummarySpreadsheet(start, end, conditions, op, { type: 'avgPerMonth' } satisfies SummaryContent, locale);","handlingStrategy":"type-guard","validationCode":"const SUPPORTED = ['sum','avgPerTransact','avgPerMonth','avgPerYear','percentage'] as const;\nif (!SUPPORTED.includes(summaryContent.type)) throw new Error(`Unsupported summary type: ${summaryContent.type}`);","typeGuard":"function isSummaryType(t: unknown): t is 'sum' | 'avgPerTransact' | 'avgPerMonth' | 'avgPerYear' | 'percentage' {\n  return typeof t === 'string' && ['sum','avgPerTransact','avgPerMonth','avgPerYear','percentage'].includes(t);\n}","tryCatchPattern":"try {\n  await builder(spreadsheet, setData);\n} catch (e) {\n  if (e instanceof Error && e.message.startsWith('Unsupported summary type')) {\n    setData({ total: 0, divisor: 0, dividend: 0, fromRange: '', toRange: '' });\n  } else throw e;\n}","preventionTips":["Type summaryContent as SummaryContent so the union is enforced at compile time","Validate persisted dashboard configs on load and migrate unknown types","Never construct SummaryContent objects with untyped string literals","Test spreadsheet builders against every member of the type union"],"tags":["reports","configuration","type-union"],"backgroundTag":"unsupported-enum-value","analyzedSha":"d4334cb6e6123f4d3bcea1ad6166608884c7e658","analyzedAt":"2026-08-29T01:02:11.213Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}