linshenkx/prompt-optimizer · error · Error

Google Drive folder creation did not return an id: ${name}

Error message

Google Drive folder creation did not return an id: ${name}

What it means

Same guard as the root folder creation, but for intermediate folders created while building a nested path (findOrCreateFolderPath). The created folder JSON lacked an id, so the path chain cannot continue.

Source

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

  private async createFolder(parentId: string, name: string): Promise<string> {
    const response = await this.fetchGoogleDrive(
      'https://www.googleapis.com/drive/v3/files?fields=id,name',
      {
        method: 'POST',
        headers: {
          'Content-Type': 'application/json',
        },
        body: JSON.stringify({
          name,
          mimeType: GOOGLE_DRIVE_FOLDER_MIME_TYPE,
          parents: [parentId],
        }),
      },
      'Google Drive folder creation failed',
    )
    const created = await response.json()
    const id = String(created.id || '')
    if (!id) throw new Error(`Google Drive folder creation did not return an id: ${name}`)
    return id
  }

  private async fetchGoogleDrive(
    url: string | URL,
    init: RequestInit,
    context: string,
    options?: { downloadRetry?: boolean },
  ): Promise<Response> {
    const response = await this.fetchGoogleDriveOnce(url, init, context, false, options)
    if (!isGoogleAuthStatus(response.status)) {
      return assertOkResponse(response, context)
    }
    await response.body?.cancel().catch(() => undefined)
    const retryResponse = await this.fetchGoogleDriveOnce(url, init, context, true, options)
    return assertOkResponse(retryResponse, context)
  }

View on GitHub (pinned to 3e677b1d9f)

Solutions

  1. Log response body and retry the folder creation
  2. Check Drive storage quota for the account
  3. Flatten the backup layout to avoid nested folder creation
Defensive patterns

Strategy: retry

Try / catch

catch (e) { if ((e as Error).message.startsWith('Google Drive folder creation did not return an id')) retry(); else throw e }

Prevention

When it happens

Trigger: Creating nested backup directories (e.g. per-date subfolders) when a Drive folder-create response omits id — partial responses, quota errors surfaced as JSON, or API changes.

Common situations: Drive quota exceeded returning an error body with 200; flaky network mid-response; mocking in tests.

Related errors


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