Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

D1 migrations in CI fail silently #221

Open
davwheat opened this issue Dec 20, 2023 · 6 comments
Open

D1 migrations in CI fail silently #221

davwheat opened this issue Dec 20, 2023 · 6 comments

Comments

@davwheat
Copy link
Contributor

davwheat commented Dec 20, 2023

I have no idea if this is a me problem like some misconfiguration I've made, but I can't work this out for the life of me.

Excerpt from my workflow:

      - name: Deploy worker
        uses: cloudflare/wrangler-action@v3
        with:
          apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
          workingDirectory: 'cf-workers'

      - name: Run D1 migrations
        uses: cloudflare/wrangler-action@v3
        with:
          apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
          workingDirectory: 'cf-workers'
          command: d1 migrations apply rail-announcements

Deploying the worker is fine, but the migrations command returns error code 1 with no useful log output:

🚀 Running Wrangler Commands
  /usr/local/bin/yarn wrangler d1 migrations apply rail-announcements
Error: The process '/usr/local/bin/yarn' failed with exit code 1
Error: 🚨 Action failed

Running it locally works fine, with the CLI output I'd expect:

ubuntu@David-PC:~/rail-announcements/cf-workers$ yarn wrangler d1 migrations apply rail-announcements
✅ No migrations to apply!

Any ideas what I might be doing wrong?

@1000hz
Copy link
Contributor

1000hz commented Dec 22, 2023

Sorry for the trouble here. It sounds like you're running into cloudflare/workers-sdk#4078.
Your API token doesn't have edit permissions for D1 so you're getting an auth error, but that wrangler d1 command doesn't properly log an error. This should be fixed in wrangler soon via cloudflare/workers-sdk#4597.

@1000hz 1000hz closed this as not planned Won't fix, can't repro, duplicate, stale Dec 22, 2023
@github-project-automation github-project-automation bot moved this from Untriaged to Done in workers-sdk Dec 22, 2023
@davwheat
Copy link
Contributor Author

Ahh, spot on! Thanks so much. :)

@vladinator1000
Copy link

vladinator1000 commented Apr 23, 2024

This also fails silently for me on wrangler 3.51.2
image

      - name: 🕊️ Migrate 
        uses: cloudflare/wrangler-action@v3
        with:
          apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
          accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
          wranglerVersion: "3.51.2"
          command: d1 migrations apply yupty-staging --remote --env staging

Fix

@compeek
Copy link

compeek commented Oct 29, 2024

This also fails silently for me on wrangler 3.51.2 image

      - name: 🕊️ Migrate 
        uses: cloudflare/wrangler-action@v3
        with:
          apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
          accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
          wranglerVersion: "3.51.2"
          command: d1 migrations apply yupty-staging --remote --env staging

Fix

Thank you, adding the D1 edit permission fixed it for me on 3.83.0 as well with wrangler d1 migrations apply. I've been dealing with this for months. It makes sense now, but the lack of any error message was very frustrating.

@jakst
Copy link

jakst commented Nov 19, 2024

@1000hz this is still happening on wrangler 3.87.0. No error message whatsoever.
image

@1000hz 1000hz reopened this Nov 19, 2024
@jahands
Copy link
Contributor

jahands commented Nov 20, 2024

I can repro this locally. Need to open an issue on workers-sdk

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants