Skip to content

Fix db-migrate workflow PlanetScale 403 on staging branch check #797

Description

@jeevanpillay

Problem

The db-migrate GitHub Actions workflow failed before running migrations because PlanetScale returned a 403 Forbidden during the staging branch existence check.

Failing workflow run:
https://github.com/lightfastai/lightfast/actions/runs/26924643122

Failing step:

pscale branch show "$PLANETSCALE_DATABASE_NAME" "$PSCALE_BRANCH_NAME" --org "$PLANETSCALE_ORG_NAME"

Observed output included an HTML PlanetScale/API response:

403 Forbidden

The workflow then printed the generic fallback message:

staging branch missing - run the one-time bootstrap documented in db/CLAUDE.md

Important Context

The staging branch was not actually missing. Local pscale branch list lightfast --org lightfast --format json showed staging exists and is ready.

PR #792 was deployed manually by:

  1. Creating a temporary local PlanetScale password for lightfast/staging.
  2. Running pnpm --filter @db/app db:migrate against staging.
  3. Opening/deploying deploy request #19 from staging into main.
  4. Running pscale deploy-request skip-revert lightfast 19 --org lightfast.
  5. Verifying no temporary codex-pr792-* password remained.

Likely Cause

The GitHub Actions PlanetScale service token may be invalid, expired, mismatched, or missing permissions for org/database access.

Secrets to verify:

  • PLANETSCALE_ORG_NAME
  • PLANETSCALE_DATABASE_NAME
  • PLANETSCALE_SERVICE_TOKEN_ID
  • PLANETSCALE_SERVICE_TOKEN

The service token should be able to:

  • Read database branches.
  • Create/delete branch passwords on staging.
  • Create/show/deploy deploy requests from staging to main.

Suggested Fix

  • Verify or rotate the PlanetScale service token used by GitHub Actions.
  • Confirm the token has the required org/database permissions.
  • Improve the workflow error handling so a PlanetScale API/auth failure is not reported as “staging branch missing.”

A better check would preserve and print the pscale branch show stderr, distinguish 403 from branch-not-found, and fail with an auth/permission-specific message.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions