cloudflare / workers-sdk

⛅️ Home to Wrangler, the CLI for Cloudflare Workers®
https://developers.cloudflare.com/workers/
Apache License 2.0
2.58k stars 665 forks source link

🐛 BUG: Cannot upload PostgreSQL dump file to R2 via cloudflare/wrangler-action@v3 #5645

Closed ojh closed 5 months ago

ojh commented 5 months ago

Which Cloudflare product(s) does this pertain to?

R2

What version(s) of the tool(s) are you using?

3.13.2 [Wrangler], 3.4.1 [wrangler-action]

What version of Node are you using?

20.12.2

What operating system and version are you using?

Linux

Describe the Bug

Observed behavior

I am unable to successfully upload any PostgreSQL dump files to R2 via cloudflare/wrangler-action@v3 (either in Posgres' native custom format or .tar, both of which I have generated directly via pg_dump).

I have tested the exact same command (albeit without specifying a content-type or content-disposition) with a plain text file, and it worked perfectly. Omitting the content-type and content-disposition with the pg_dump file results in the same error as above.

Expected behavior

The action should succeed and the file should be uploaded to my R2 bucket.

Steps to reproduce

This is what the relevant part of my Github Actions workflow file looks like:

jobs:
  backup-db:
    name: Backup DB
    runs-on: ubuntu-latest
    container: postgres:15-alpine

    steps:
      - uses: actions/checkout@v4

      - name: Backup database
        run: pg_dump -Fc -v -d ${{ secrets.DATABASE_URL }} -f db.dump

      - name: Archive DB backup
        uses: actions/upload-artifact@v4
        with:
          name: database-backup
          path: db.dump

  send-to-r2:
    name: Backup DB dump file to R2 bucket
    runs-on: ubuntu-latest
    needs:
      - backup-db

    steps:
      - uses: actions/checkout@v4

      - uses: actions/download-artifact@v4
        with:
          name: database-backup
          path: db.dump

      - name: Upload backup to R2 bucket
        uses: cloudflare/wrangler-action@v3
        with:
          apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
          accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
          command: r2 object put my-existing-bucket/db.dump --file db.dump  --content-type application/octet-stream --content-disposition attachment

I'm not convinced that this is a bug, but I can't think of what else I might have missed here. Any suggestions would be greatly appreciated.

Please provide a link to a minimal reproduction

No response

Please provide any relevant error logs

🚀 Running Wrangler Commands
  /usr/local/bin/npx wrangler r2 object put my-existing-bucket/db.dump --file db.dump --content-type application/octet-stream --content-disposition attachment
   ⛅️ wrangler 3.13.2 (update available 3.51.0)
  ---------------------------------------------
  Creating object "db.dump" in bucket "my-existing-bucket".
  ✘ [ERROR] fetch failed
  If you think this is a bug then please create an issue at https://github.com/cloudflare/workers-sdk/issues/new/choose
Error: The process '/usr/local/bin/npx' failed with exit code 1
Error: 🚨 Action failed
ojh commented 5 months ago

Apologies, this turned out to be due to an error in my Github Actions workflow.