{"record":{"id":"56a7c000e5476be6","repo":"davila7/claude-code-templates","slug":"invalid-cache-type-use-all-or-conversations","errorCode":null,"errorMessage":"Invalid cache type. Use \"all\" or \"conversations\"","messagePattern":"Invalid cache type\\. Use \"all\" or \"conversations\"","errorType":"http","errorClass":null,"httpStatus":400,"severity":"warning","filePath":"cli-tool/src/analytics.js","lineNumber":1179,"sourceCode":"    this.app.post('/api/cache/clear', (req, res) => {\n      try {\n        // Clear specific cache types or all\n        const { type } = req.body;\n        \n        if (!type || type === 'all') {\n          // Clear all caches\n          this.dataCache.invalidateComputations();\n          this.dataCache.caches.parsedConversations.clear();\n          this.dataCache.caches.fileContent.clear();\n          this.dataCache.caches.fileStats.clear();\n          res.json({ success: true, message: 'All caches cleared' });\n        } else if (type === 'conversations') {\n          // Clear only conversation-related caches\n          this.dataCache.caches.parsedConversations.clear();\n          this.dataCache.caches.fileContent.clear();\n          res.json({ success: true, message: 'Conversation caches cleared' });\n        } else {\n          res.status(400).json({ error: 'Invalid cache type. Use \"all\" or \"conversations\"' });\n        }\n      } catch (error) {\n        console.error('Error clearing cache:', error);\n        res.status(500).json({ error: 'Failed to clear cache' });\n      }\n    });\n\n    // Clear cache endpoint\n    this.app.post('/api/clear-cache', async (req, res) => {\n      try {\n        console.log('🔥 Clear cache request received');\n        \n        // Clear DataCache\n        if (this.dataCache && typeof this.dataCache.clear === 'function') {\n          this.dataCache.clear();\n          console.log('🔥 Server DataCache cleared');\n        } else {\n          console.log('⚠️ DataCache not available or no clear method');","sourceCodeStart":1161,"sourceCodeEnd":1197,"githubUrl":"https://github.com/davila7/claude-code-templates/blob/a0851ed10c7c60463dac8cfaaca124cf32d5804d/cli-tool/src/analytics.js#L1161-L1197","documentation":"400 from the cache-clear endpoint: the ?type= query parameter was neither 'all' nor 'conversations'. This is intentional input validation, not a crash.","triggerScenarios":"POST /api/clear-cache?type=cache or any other/missing type value (empty string, 'conv', 'messages', case variants like 'ALL').","commonSituations":"Client code passing a wrong enum value; documentation drift where callers assume other cache names exist; case-sensitive mismatch.","solutions":["Use exactly ?type=all or ?type=conversations","Lowercase the value client-side before sending","Update the calling code/script that hardcodes an unsupported type"],"exampleFix":"// before\nawait fetch(`${base}/api/clear-cache?type=messages`, { method: 'POST' });\n// after\nawait fetch(`${base}/api/clear-cache?type=all`, { method: 'POST' });","handlingStrategy":"validation","validationCode":"const type = ['all', 'conversations'].includes(rawType) ? rawType : 'all';\nawait fetch(`${base}/api/clear-cache?type=${type}`, { method: 'POST' });","typeGuard":"const isCacheType = (t) => t === 'all' || t === 'conversations';","tryCatchPattern":"try { ... } catch (e) { if (e.response?.status === 400) throw new Error(`bad cache type: ${sentType}`); }","preventionTips":["Whitelist the enum client-side","Lowercase user-supplied type values before sending"],"tags":["analytics","express","http-400","input-validation"],"backgroundTag":"invalid-query-parameter","analyzedSha":"a0851ed10c7c60463dac8cfaaca124cf32d5804d","analyzedAt":"2026-08-28T14:11:56.058Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}