{"record":{"id":"ca088ac5d4f62ada","repo":"actualbudget/actual","slug":"error-loading-data-into-the-spreadsheet","errorCode":null,"errorMessage":"Error loading data into the spreadsheet.","messagePattern":"Error loading data into the spreadsheet\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/desktop-client/src/components/reports/ReportOptions.ts","lineNumber":444,"sourceCode":"      break;\n    case 'Payee':\n      groupByList = payees.map(payee => {\n        return { id: payee.id, name: payee.name, hidden: false };\n      });\n      groupByLabel = 'payee';\n      break;\n    case 'Account':\n      groupByList = accounts.map(account => {\n        return { id: account.id, name: account.name, hidden: false };\n      });\n      groupByLabel = 'account';\n      break;\n    case 'Interval':\n      groupByList = categoryList;\n      groupByLabel = 'category';\n      break;\n    default:\n      throw new Error('Error loading data into the spreadsheet.');\n  }\n  return [groupByList, groupByLabel];\n};\n","sourceCodeStart":426,"sourceCodeEnd":448,"githubUrl":"https://github.com/actualbudget/actual/blob/d4334cb6e6123f4d3bcea1ad6166608884c7e658/packages/desktop-client/src/components/reports/ReportOptions.ts#L426-L448","documentation":"groupBySelections in ReportOptions.ts switches on the report's `groupBy` selection ('Category', 'Group', 'CategoryGroup', 'Payee', 'Account', 'Interval') to pick the list and label used to load report spreadsheet data. The default branch throws this generic error when groupBy holds an unrecognized value. Because the value is typed as plain `string`, TypeScript cannot guarantee validity, so this runtime check reports an invalid report configuration as a data-loading failure.","triggerScenarios":"Calling groupBySelections with a groupBy value outside the handled set — e.g. a persisted report config saved with an old/renamed grouping option ('category' lowercase, 'month', etc.), or custom report code passing a new grouping mode without adding a case here.","commonSituations":"Restoring report settings from synced prefs or localStorage written by a different app version where grouping keys were renamed; plugins or custom reports passing their own grouping values; case-sensitivity mistakes when constructing the groupBy string.","solutions":["Log the groupBy value at the throw to see the invalid string.","Add a case for the missing grouping option (or map it to an existing one) in groupBySelections.","Migrate/normalize persisted report configs to current grouping keys before rendering the report.","Restrict the groupBy parameter type to the allowed literal union so invalid values fail at compile time."],"exampleFix":"// before\ntype GroupBy = string;\n// after\ntype GroupBy = 'Category' | 'Group' | 'CategoryGroup' | 'Payee' | 'Account' | 'Interval';\nexport const groupBySelections = (groupBy: GroupBy, ...) => ...","handlingStrategy":"validation","validationCode":"const VALID_GROUP_BY = ['Category','Group','CategoryGroup','Payee','Account','Interval'];\nif (!VALID_GROUP_BY.includes(groupBy)) {\n  groupBy = 'Category'; // safe default\n}","typeGuard":"type GroupBy = 'Category' | 'Group' | 'CategoryGroup' | 'Payee' | 'Account' | 'Interval';\nfunction isGroupBy(v: string): v is GroupBy {\n  return ['Category','Group','CategoryGroup','Payee','Account','Interval'].includes(v);\n}","tryCatchPattern":"try {\n  const [list, label] = groupBySelections(groupBy, categories, groups, payees, accounts);\n} catch {\n  const [list, label] = groupBySelections('Category', categories, groups, payees, accounts);\n}","preventionTips":["Type groupBy as a literal union instead of string so invalid values are caught at compile time.","Migrate persisted report settings when grouping keys change between versions.","Compare grouping values case-sensitively and consistently everywhere ('Category', not 'category').","Fall back to a default grouping instead of crashing the whole report."],"tags":["reports","spreadsheet","configuration","typescript"],"backgroundTag":"invalid-enum-value","analyzedSha":"d4334cb6e6123f4d3bcea1ad6166608884c7e658","analyzedAt":"2026-08-29T01:02:11.213Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}