linshenkx/prompt-optimizer · error · Error

Google Drive resumable upload session did not return a locat

Error message

Google Drive resumable upload session did not return a location

What it means

The Google Drive provider starts a resumable upload by POSTing metadata and expects a Location header with the upload URL. If Drive's response omits Location, the upload cannot proceed and this error is thrown.

Source

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

      name,
      mimeType: blob.type || JSON_MIME_TYPE,
      parents: [parentId],
    }
    const sessionResponse = await this.fetchGoogleDrive(
      'https://www.googleapis.com/upload/drive/v3/files?uploadType=resumable&fields=id,name,size,modifiedTime,mimeType',
      {
        method: 'POST',
        headers: {
          'Content-Type': 'application/json; charset=UTF-8',
          'X-Upload-Content-Type': blob.type || JSON_MIME_TYPE,
          'X-Upload-Content-Length': String(blob.size),
        },
        body: JSON.stringify(metadata),
      },
      'Google Drive resumable upload session failed',
    )
    const uploadUrl = sessionResponse.headers.get('Location')
    if (!uploadUrl) throw new Error('Google Drive resumable upload session did not return a location')

    const uploadResponse = await assertOkResponse(await fetch(uploadUrl, {
      method: 'PUT',
      headers: {
        'Content-Type': blob.type || JSON_MIME_TYPE,
      },
      body: blob,
    }), 'Google Drive resumable upload failed')
    const file = await uploadResponse.json()
    this.pathIdCache.set(path, String(file.id || ''))
    return {
      path,
      sizeBytes: typeof file.size === 'string' ? Number(file.size) : blob.size,
      updatedAt: typeof file.modifiedTime === 'string' ? file.modifiedTime : new Date().toISOString(),
      contentType: typeof file.mimeType === 'string' ? file.mimeType : blob.type,
    }
  }

View on GitHub (pinned to 3e677b1d9f)

Solutions

  1. Retry the upload once (transient header loss)
  2. Inspect network response headers in devtools to confirm Location is missing; bypass proxy/extension
  3. Fall back to simple (multipart) upload path

Example fix

// before
const uploadUrl = sessionResponse.headers.get('Location')
// after
const uploadUrl = sessionResponse.headers.get('Location')
if (!uploadUrl) {
  return this.simpleUpload(normalized, blob) // fallback
}
Defensive patterns

Strategy: retry

Try / catch

try { await store.put(path, blob) } catch (e) { if ((e as Error).message.includes('resumable upload session')) return retryWithBackoff(() => store.put(path, blob)); throw e }

Prevention

When it happens

Trigger: POST to https://www.googleapis.com/upload/drive/v3/files?uploadType=resumable succeeded (2xx) but headers lacked Location; caused by proxies stripping redirect headers, misconfigured fetch shim, or Drive API behavior changes.

Common situations: Corporate proxies or service workers rewriting responses; browser extensions; rare API changes. Very low frequency since assertOkResponse already gates non-2xx.

Related errors


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