{"record":{"id":"9928e490cc46e0f3","repo":"paperclipai/paperclip","slug":"routinekey-is-required-valid-values-wiki-maint","errorCode":null,"errorMessage":"routineKey is required; valid values: ${WIKI_MAINTENANCE_ROUTINE_KEYS.join(\", \")}","messagePattern":"routineKey is required; valid values: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/plugins/plugin-llm-wiki/src/worker.ts","lineNumber":71,"sourceCode":"  selectWikiAgentResource,\n  selectWikiProjectResource,\n  startWikiQuerySession,\n  spaceFolderStatus,\n  updateEventIngestionSettings,\n  updatePaperclipIngestionProfile,\n  updateSpace,\n  writeTemplate,\n  writeWikiPage,\n} from \"./wiki.js\";\n\nfunction stringField(value: unknown): string | null {\n  return typeof value === \"string\" && value.trim().length > 0 ? value.trim() : null;\n}\n\nfunction routineKeyField(value: unknown): (typeof WIKI_MAINTENANCE_ROUTINE_KEYS)[number] {\n  const routineKey = stringField(value);\n  if (!routineKey) {\n    throw new Error(`routineKey is required; valid values: ${WIKI_MAINTENANCE_ROUTINE_KEYS.join(\", \")}`);\n  }\n  if (!WIKI_MAINTENANCE_ROUTINE_KEYS.includes(routineKey as (typeof WIKI_MAINTENANCE_ROUTINE_KEYS)[number])) {\n    throw new Error(`Unknown managed routine: ${routineKey}`);\n  }\n  return routineKey as (typeof WIKI_MAINTENANCE_ROUTINE_KEYS)[number];\n}\n\nfunction routineOverridesFromParams(params: Record<string, unknown>) {\n  const overrides: { assigneeAgentId?: string; projectId?: string } = {};\n  const assigneeAgentId = stringField(params.assigneeAgentId);\n  const projectId = stringField(params.projectId);\n  if (assigneeAgentId) overrides.assigneeAgentId = assigneeAgentId;\n  if (projectId) overrides.projectId = projectId;\n  return overrides;\n}\n\nlet activeContext: PluginContext | null = null;\nconst PAPERCLIP_EVENT_INGESTION_EVENTS = [","sourceCodeStart":53,"sourceCodeEnd":89,"githubUrl":"https://github.com/paperclipai/paperclip/blob/67001ec6eb96ae601aa27bc91d9b2415d665334a/packages/plugins/plugin-llm-wiki/src/worker.ts#L53-L89","documentation":"Thrown by routineKeyField in worker.ts when the routineKey param is missing or blank after trimming. routineKeyField powers managed-routine actions (reset/update) and must resolve to one of the WIKI_MAINTENANCE_ROUTINE_KEYS. The empty-check precedes the membership check.","triggerScenarios":"Invoking a managed-routine worker action (e.g. reset-managed-routine) without routineKey, with an empty string, or with a whitespace-only value.","commonSituations":"Action caller forgot the param; param spelled 'routine_key' or 'routine' instead of 'routineKey'; a generic routine dispatcher forwarded params but dropped routineKey.","solutions":["Pass routineKey as one of: 'cursor-window-processing', 'nightly-wiki-lint', 'index-refresh'.","Check the param name spelling (camelCase routineKey).","Default the param at the caller if a specific routine is implied by context."],"exampleFix":"// before\nctx.actions.run('reset-managed-routine', { companyId });\n// after\nctx.actions.run('reset-managed-routine', { companyId, routineKey: 'nightly-wiki-lint' });","handlingStrategy":"validation","validationCode":"const WIKI_MAINTENANCE_ROUTINE_KEYS = ['cursor-window-processing', 'nightly-wiki-lint', 'index-refresh'] as const;\nfunction assertRoutineKey(value: unknown) {\n  if (typeof value !== 'string' || !value.trim()) throw new Error('routineKey is required');\n  if (!WIKI_MAINTENANCE_ROUTINE_KEYS.includes(value as any)) throw new Error(`Unknown managed routine: ${value}`);\n}","typeGuard":"const WIKI_MAINTENANCE_ROUTINE_KEYS = ['cursor-window-processing', 'nightly-wiki-lint', 'index-refresh'] as const;\nfunction isRoutineKey(value: unknown): value is typeof WIKI_MAINTENANCE_ROUTINE_KEYS[number] {\n  return typeof value === 'string' && (WIKI_MAINTENANCE_ROUTINE_KEYS as readonly string[]).includes(value);\n}","tryCatchPattern":null,"preventionTips":["Always pass routineKey on managed-routine actions.","Use the exact key spelling from manifest.ts."],"tags":["paperclip","wiki","routine","validation"],"backgroundTag":null,"analyzedSha":"67001ec6eb96ae601aa27bc91d9b2415d665334a","analyzedAt":"2026-08-12T12:05:45.408Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}