{"record":{"id":"95278b197e4fd201","repo":"overleaf/overleaf","slug":"failed-to-list-objects-in-gcs","errorCode":null,"errorMessage":"failed to list objects in GCS","messagePattern":"failed to list objects in GCS","errorType":"exception","errorClass":"ReadError","httpStatus":null,"severity":"error","filePath":"libraries/object-persistor/src/GcsPersistor.js","lineNumber":298,"sourceCode":"          { bucketName, key },\n          WriteError\n        )\n        if (error instanceof NotFoundError) {\n          return\n        }\n        throw error\n      }\n    } while (query)\n  }\n\n  async #listDirectory(bucketName, prefix) {\n    try {\n      const [response] = await this.storage\n        .bucket(bucketName)\n        .getFiles({ prefix })\n      return response\n    } catch (err) {\n      throw PersistorHelper.wrapError(\n        err,\n        'failed to list objects in GCS',\n        { bucketName, prefix },\n        ReadError\n      )\n    }\n  }\n\n  async directorySize(bucketName, key) {\n    const prefix = ensurePrefixIsDirectory(key)\n    const files = await this.#listDirectory(bucketName, prefix)\n\n    return files.reduce(\n      (acc, file) => parseInt(file.metadata.size, 10) + acc,\n      0\n    )\n  }\n","sourceCodeStart":280,"sourceCodeEnd":316,"githubUrl":"https://github.com/overleaf/overleaf/blob/28ad3b03b71cb4311decdcb55c36b33ec10d72db/libraries/object-persistor/src/GcsPersistor.js#L280-L316","documentation":"Thrown by the private #listDirectory helper in GcsPersistor when bucket.getFiles({prefix}) fails (permission, missing bucket, or API fault). The raw error is wrapped into a ReadError with bucketName/prefix context; directorySize and files depend on this listing.","triggerScenarios":"Thrown at libraries/object-persistor/src/GcsPersistor.js:298 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Verify the bucket exists and the service account can list it","Check the prefix is well-formed for the directory layout","Inspect the wrapped cause for the GCS error","Retry transient GCS API failures with backoff"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"28ad3b03b71cb4311decdcb55c36b33ec10d72db","analyzedAt":"2026-09-03T02:10:22.807Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-10T07:17:11.731Z"}