{"record":{"id":"77fa6b0500524443","repo":"hcengineering/platform","slug":"key-cannot-be-empty","errorCode":null,"errorMessage":"Key cannot be empty","messagePattern":"Key cannot be empty","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pods/preview/src/cache.ts","lineNumber":168,"sourceCode":"      } catch (err) {\n        this.ctx.error('Failed to move file to cache', { filePath, error: err })\n        throw err\n      }\n    }\n\n    const entry = { ...value, filePath, size }\n    this.cache.set(key, entry)\n\n    return entry\n  }\n\n  async delete (key: string): Promise<void> {\n    this.cache.delete(key)\n  }\n\n  private getFilePath (key: string): string {\n    if (key.length === 0) {\n      throw new Error('Key cannot be empty')\n    }\n\n    if (key.includes('..') || key.includes('./') || key.includes('/.')) {\n      throw new Error('Key contains invalid path sequences')\n    }\n\n    key = key.replace(/[^a-zA-Z0-9-_/]/g, '_')\n    const path = join(this.cachePath, key)\n\n    if (!this.isPathWithinCache(path)) {\n      throw new Error('Cache path is outside of cache directory')\n    }\n\n    return path\n  }\n\n  private isPathWithinCache (filePath: string): boolean {\n    const normalizedPath = resolve(normalize(filePath))","sourceCodeStart":150,"sourceCodeEnd":186,"githubUrl":"https://github.com/hcengineering/platform/blob/63e28dc96483967b2fc21c881b3f1023c1de7718/pods/preview/src/cache.ts#L150-L186","documentation":"Error thrown by the private getFilePath helper when given an empty key. getFilePath is called by put (and other operations) to convert a key into a filesystem path; empty keys are rejected before path construction.","triggerScenarios":"cache.put('', value) or other cache operations passing '' internally, mirroring error 466's empty-key condition at the path-resolution layer.","commonSituations":"Same root causes as 'Invalid key': empty hash results, unset key variables, or upstream data loss where the URL/identifier used as key was blank.","solutions":["Ensure keys are non-empty before any cache operation (validate at the API boundary)","Fix the key-generation function to reject/repair empty inputs","Cache-miss behavior: treat empty key as a cache bypass rather than an error if acceptable","Trace with a breakpoint/log on getFilePath to find who supplies the empty key"],"exampleFix":"// before\nconst path = cache.getFilePath(key) // throws if key === ''\n// after\nconst path = key ? cache.getFilePath(key) : null\nif (path) { /* use cached file */ }","handlingStrategy":"validation","validationCode":"if (typeof key !== 'string' || key.length === 0) return null","typeGuard":null,"tryCatchPattern":"try {\n  await cache.put(key, value)\n} catch (e) {\n  if (e.message === 'Key cannot be empty') return null\n  throw e\n}","preventionTips":["Guard empty keys at the cache call sites","Fix key-derivation to always produce non-empty digests","Add unit tests for empty-key inputs","Log when empty keys are skipped for observability"],"tags":["validation","cache","keys"],"backgroundTag":"invalid-cache-key","analyzedSha":"63e28dc96483967b2fc21c881b3f1023c1de7718","analyzedAt":"2026-08-29T15:21:27.377Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}