Skip to content

Error when running "backup" demo: Session not found. You may need to login again with sanity login. #23

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

Open
newt-beach opened this issue Mar 11, 2024 · 2 comments

Comments

@newt-beach
Copy link

newt-beach commented Mar 11, 2024

Describe the bug

I get the following message trying to run the backup demonstration in the README:
Error: Unauthorized - Session not found. You may need to login again with sanity login.

I have set SANITY_AUTH_TOKEN in my repository secrets. I have tried using several Sanity API tokens: one with the deploy-studio designation, one developer token and one viewer token. However, they all throw the same error.

According to the docs this message could mean:

    - A temporary issue, please try to run your command again.
    - You have specified an invalid token with the SANITY_AUTH_TOKEN env variable.
    - The session timed out. Try to log out and log in again with the sanity logout and sanity login CLI commands.
    - There was an issue with your logged in user. Try to logout and login again.

I'm confused here because my understanding of deploy tokens is that sanity login shouldn't be required. So, reasons 3 & 4 don't apply when I get that error using a deploy token.

To Reproduce
I copied the code from the "backup" demo in the readme, with a small modification to run the workflow manually instead of on a cron job. Here is the full code of my workflow:

name: "Backup prod CMS"
on:
  workflow_dispatch:
jobs:
  backup-dataset:
    runs-on: ubuntu-latest
    name: Backup dataset
    steps:
      - uses: actions/checkout@v2
      - run: yarn install
      - name: Export dataset
        uses: sanity-io/[email protected]
        env:
          SANITY_AUTH_TOKEN: ${{ secrets.SANITY_AUTH_TOKEN }}
        with:
          args: dataset export production backups/backup.tar.gz
      - name: Upload backup.tar.gz
        uses: actions/upload-artifact@v2
        with:
          name: backup-tarball
          path: backups/backup.tar.gz
          # Fails the workflow if no files are found; defaults to 'warn'
          if-no-files-found: error
@tharnach
Copy link

I'm also having the same issue. Just wanted to point out there haven't been any service disruptions reported either.

@obrassard
Copy link

I faced the same issue when trying to deploy the studio.
For now the simplest solution I found was to bypass sanity-io/github-action-sanity and use the sanity cli directly :

name: Deploy Sanity
on:
  push:
    branches: [main]
jobs:
  sanity-deploy:
    runs-on: ubuntu-latest
    name: Deploy Sanity
    steps:
      - name: Checkout Repository
        uses: actions/checkout@v4

      - name: Install Packages
        run: npm install

      - name: Deploy Sanity
        run: npm run deploy
        env:
          SANITY_AUTH_TOKEN: ${{ secrets.SANITY_AUTH_TOKEN }}

I believe using run: sanity dataset export production backups/backup.tar.gz would work as well

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

3 participants