{"record":{"id":"1e02cbb922922800","repo":"hcengineering/platform","slug":"failed-to-delete-file-1e02cb","errorCode":null,"errorMessage":"Failed to delete file","messagePattern":"Failed to delete file","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"foundations/core/packages/storage-client/src/client/hulylake.ts","lineNumber":54,"sourceCode":"    return getPathname(url)\n  }\n\n  async getFileMeta (token: string, workspace: string, file: string): Promise<Record<string, any>> {\n    return {}\n  }\n\n  async deleteFile (token: string, workspace: string, file: string): Promise<void> {\n    const url = this.getFileUrl(workspace, file)\n\n    const response = await fetch(url, {\n      method: 'DELETE',\n      headers: {\n        Authorization: `Bearer ${token}`\n      }\n    })\n\n    if (!response.ok) {\n      throw new Error('Failed to delete file')\n    }\n  }\n\n  async uploadFile (\n    token: string,\n    workspace: string,\n    uuid: string,\n    file: File,\n    options?: FileStorageUploadOptions\n  ): Promise<void> {\n    const url = this.getFileUrl(workspace, uuid)\n\n    await uploadXhr(\n      {\n        url,\n        method: 'PUT',\n        headers: {\n          Authorization: `Bearer ${token}`,","sourceCodeStart":36,"sourceCodeEnd":72,"githubUrl":"https://github.com/hcengineering/platform/blob/63e28dc96483967b2fc21c881b3f1023c1de7718/foundations/core/packages/storage-client/src/client/hulylake.ts#L36-L72","documentation":"HulylakeStorage.deleteFile performs DELETE <baseUrl>/blob/<workspace>/<file> with a Bearer token and throws this generic Error if the response is not ok. The client throws away the status and body, so 401/403/404/5xx all surface as the same message.","triggerScenarios":"deleteFile(token, workspace, file) receives a non-2xx: invalid/expired token, unknown workspace or file UUID, huly lake service error (500/503), or an ingress/proxy rejecting the DELETE.","commonSituations":"Env-specific baseUrl misconfiguration (pointing at datalake instead of huly lake); token obtained for a different workspace/region; object already deleted by a concurrent process; storage backend outage returning 503.","solutions":["Log or intercept response.status to determine whether it is auth (401/403), missing object (404) or server error (5xx).","Refresh the Bearer token and retry once on auth failures.","Verify workspace/file identifiers and that the baseUrl matches the deployed huly lake service.","Retry with backoff on 5xx; treat 404 as already-deleted success if your workflow allows."],"exampleFix":"// before\nawait storage.deleteFile(token, workspace, file) // 404 also throws\n\n// after: tolerate already-deleted objects\ntry { await storage.deleteFile(token, workspace, file) }\ncatch { /* check meta; if absent, treat as deleted */ }","handlingStrategy":"try-catch","validationCode":"// verify the object exists and the config points at huly lake before deleting\nconst meta = await storage.getFileMeta(token, workspace, file)\nif (Object.keys(meta).length === 0) return // already gone\nconsole.assert(storageBaseUrl.includes('huly'), 'check baseUrl targets huly lake')","typeGuard":"null","tryCatchPattern":"try {\n  await storage.deleteFile(token, workspace, file)\n} catch (err) {\n  if (err instanceof Error && err.message === 'Failed to delete file') {\n    // probe status via a manual fetch to /meta to classify 401 vs 404 vs 5xx\n  } else throw err\n}","preventionTips":["Match baseUrl to the deployed huly lake service per environment.","Refresh tokens before scheduled deletion tasks.","Skip (or log-and-continue) deletes of objects already absent.","Add retries with backoff for 5xx responses."],"tags":["storage","http","network","delete"],"backgroundTag":"storage-delete-request-failed","analyzedSha":"63e28dc96483967b2fc21c881b3f1023c1de7718","analyzedAt":"2026-08-29T15:21:27.377Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}