{"record":{"id":"25d0bf1d7e229881","repo":"thedotmack/claude-mem","slug":"invalid-operation","errorCode":null,"errorMessage":"Invalid operation","messagePattern":"Invalid operation","errorType":"http","errorClass":null,"httpStatus":400,"severity":"warning","filePath":"src/services/server/Server.ts","lineNumber":298,"sourceCode":"          message: 'Worker is still initializing, please retry',\n        });\n      }\n    });\n\n    this.app.get('/api/version', (_req: Request, res: Response) => {\n      res.status(200).json({ version: BUILT_IN_VERSION });\n    });\n\n    this.app.get('/api/instructions', (req: Request, res: Response) => {\n      const topic = (req.query.topic as string) || 'all';\n      const operation = req.query.operation as string | undefined;\n\n      if (topic && !ALLOWED_TOPICS.includes(topic)) {\n        return res.status(400).json({ error: 'Invalid topic' });\n      }\n\n      if (operation && !ALLOWED_OPERATIONS.includes(operation)) {\n        return res.status(400).json({ error: 'Invalid operation' });\n      }\n\n      if (operation) {\n        const cached = cachedOperationContent.get(operation);\n        if (cached === undefined) {\n          logger.debug('HTTP', 'Instruction file not cached at boot', { operation });\n          return res.status(404).json({ error: 'Instruction not found' });\n        }\n        return res.json({ content: [{ type: 'text', text: cached }] });\n      }\n\n      if (cachedSkillMd === null) {\n        logger.debug('HTTP', 'SKILL.md not cached at boot', { topic });\n        return res.status(404).json({ error: 'Instruction not found' });\n      }\n      const sectionText = this.extractInstructionSection(cachedSkillMd, topic);\n      res.json({ content: [{ type: 'text', text: sectionText }] });\n    });","sourceCodeStart":280,"sourceCodeEnd":316,"githubUrl":"https://github.com/thedotmack/claude-mem/blob/d8bc9755e74915e5c3b999181e10a67c889bce2a/src/services/server/Server.ts#L280-L316","documentation":"The worker Server's instruction-lookup route validates the `operation` query parameter against ALLOWED_OPERATIONS before serving cached instruction content. If the operation is not on the allow-list, it responds 400 with 'Invalid operation' instead of looking up content. This is an input allow-list guard, not a runtime fault.","triggerScenarios":"GET to the instructions endpoint with ?operation=<name> where the name is misspelled, renamed in a newer version, or is a topic-style value passed as an operation.","commonSituations":"Clients hardcoding an operation string that changed when the instruction set was updated; passing a topic name into the operation parameter; typos in integrations or scripts.","solutions":["Check ALLOWED_OPERATIONS in src/services/server/Server.ts and use one of the listed values","Fix the operation name in the calling client to match the current allow-list","If a new operation is legitimately needed, add its instruction file and register it in ALLOWED_OPERATIONS"],"exampleFix":"// before\nGET /api/instructions?operation=memory-save\n// after\nGET /api/instructions?operation=memory_save","handlingStrategy":"validation","validationCode":"const ALLOWED = ['memory_save','memory_retrieve']; // mirror ALLOWED_OPERATIONS\nif (!ALLOWED.includes(operation)) throw new Error(`Invalid operation: ${operation}`);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Derive the operation list from the server's allow-list rather than hardcoding","Centralize instruction operation names in a shared constant","Validate query params in client code before sending"],"tags":["http","validation","allowlist"],"backgroundTag":"invalid-enum-value","analyzedSha":"d8bc9755e74915e5c3b999181e10a67c889bce2a","analyzedAt":"2026-09-17T16:40:26.182Z","contentChangedAt":"2026-09-17T16:40:26.182Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}