linshenkx/prompt-optimizer · error · Error

Google Drive folder creation did not return an id

Error message

Google Drive folder creation did not return an id

What it means

After POSTing to create the root backup folder in Google Drive, the provider reads created.id from the JSON response. If the response has no id field, it throws because subsequent path resolution depends on the folder id.

Source

Thrown at packages/ui/src/utils/remote-backup.ts:1094

    }

    const createResponse = await this.fetchGoogleDrive(
      'https://www.googleapis.com/drive/v3/files?fields=id,name',
      {
        method: 'POST',
        headers: {
          'Content-Type': 'application/json',
        },
        body: JSON.stringify({
          name: folderName,
          mimeType: GOOGLE_DRIVE_FOLDER_MIME_TYPE,
        }),
      },
      'Google Drive folder creation failed',
    )
    const created = await createResponse.json()
    this.rootFolderId = String(created.id || '')
    if (!this.rootFolderId) throw new Error('Google Drive folder creation did not return an id')
    this.pathIdCache.set('', this.rootFolderId)
    return this.rootFolderId
  }

  private async findOrCreateFolderPath(path: string): Promise<string> {
    const normalized = normalizeObjectPath(path)
    if (!normalized) return this.ensureRootFolderId()
    const cached = this.pathIdCache.get(normalized)
    if (cached) return cached

    let currentId = await this.ensureRootFolderId()
    let currentPath = ''
    for (const segment of normalized.split('/').filter(Boolean)) {
      currentPath = joinRemotePath(currentPath, segment)
      const cachedSegment = this.pathIdCache.get(currentPath)
      if (cachedSegment) {
        currentId = cachedSegment
        continue

View on GitHub (pinned to 3e677b1d9f)

Solutions

  1. Log the full createResponse body to see what Drive actually returned
  2. Retry folder creation; transient API glitches can return incomplete bodies
  3. Check for corporate proxies/mocks altering Drive API responses
Defensive patterns

Strategy: retry

Try / catch

try { await store.put(...) } catch (e) { if ((e as Error).message.includes('folder creation')) await sleep(1000).then(() => store.put(...)); throw e }

Prevention

When it happens

Trigger: Drive folder creation endpoint returns 2xx JSON without an id — malformed proxy response, API version change, or an error body that still parsed as JSON.

Common situations: Rare; usually a proxy/mocking layer returning unexpected JSON during tests or a Drive API regression.

Related errors


AI-assisted analysis of linshenkx/prompt-optimizer@3e677b1d9f (2026-08-27). Data as JSON: /api/errors/7b529f551816ad06. Report an issue: GitHub.