Deploy logs indicate staging Sanity Dataset; however, production content being built

Hi!

I’m running into an issue where my “staging” branch deploy isn’t using the content from our “staging” dataset, despite being configured to do so. Posting additional context, configs, and deploy logs below:

Staging URL: https://staging--phil-young.netlify.app/

Stack: Sanity + Gridsome

Config:

// netlify.toml

[[redirects]]
  from = "/*"
  to = "/"
  status = 200

[context.branch-deploy]
  environment = { GRIDSOME_SANITY_DATASET = 'staging' }
  NODE_ENV = "development"

[context.staging]
  environment = { GRIDSOME_SANITY_DATASET = 'staging' }
  NODE_ENV = "development"
// sanity.json
...
  "env": {
    "development": {
      "api": {
        "dataset": "staging"
      }
    }
  },
  "__experimental_spaces": [
    {
      "name": "production",
      "title": "Production",
      "default": true,
      "api": {
        "projectId": "xxxxxxx",
        "dataset": "production"
      }
    },
    {
      "name": "staging",
      "title": "Staging",
      "api": {
        "projectId": "xxxxxxx",
        "dataset": "staging"
      }
    }
  ],
...

Build Logs:

12:17:00 PM: Build ready to start
12:17:02 PM: build-image version: 6ac9cdbcc295289dbaea7d39b2f1a3ac25ad3380 (xenial)
12:17:02 PM: build-image tag: release-v3.14.0
12:17:02 PM: buildbot version: 17781eb43cf82ba1890150fe75c9ab9320d6a721
12:17:02 PM: Fetching cached dependencies
12:17:02 PM: Starting to download cache of 108.9MB
12:17:03 PM: Finished downloading cache in 1.205483394s
12:17:03 PM: Starting to extract cache
12:17:04 PM: Finished extracting cache in 1.065790981s
12:17:04 PM: Finished fetching cache in 2.321027886s
12:17:04 PM: Starting to prepare the repo for build
12:17:05 PM: Preparing Git Reference refs/heads/staging
12:17:05 PM: Parsing package.json dependencies
12:17:06 PM: Different build dir detected, going to use the one specified in the Netlify configuration file: '' versus '/' in the Netlify UI
12:17:06 PM: Different publish path detected, going to use the one specified in the Netlify configuration file: 'web/dist' versus '/web/dist' in the Netlify UI
12:17:06 PM: Starting build script
12:17:06 PM: Installing dependencies
12:17:06 PM: Python version set to 2.7
12:17:07 PM: Started restoring cached node version
12:17:08 PM: Finished restoring cached node version
12:17:08 PM: v12.18.0 is already installed.
12:17:08 PM: Now using node v12.18.0 (npm v6.14.4)
12:17:08 PM: Started restoring cached build plugins
12:17:08 PM: Finished restoring cached build plugins
12:17:09 PM: Attempting ruby version 2.7.1, read from environment
12:17:09 PM: Started restoring cached ruby version
12:17:09 PM: Finished restoring cached ruby version
12:17:10 PM: Using ruby version 2.7.1
12:17:10 PM: Using PHP version 5.6
12:17:10 PM: No npm workspaces detected
12:17:10 PM: Started restoring cached node modules
12:17:10 PM: Finished restoring cached node modules
12:17:11 PM: Started restoring cached go cache
12:17:11 PM: Finished restoring cached go cache
12:17:11 PM: go version go1.14.4 linux/amd64
12:17:11 PM: go version go1.14.4 linux/amd64
12:17:11 PM: Installing missing commands
12:17:11 PM: Verify run directory
12:17:12 PM: ​
12:17:12 PM: ────────────────────────────────────────────────────────────────
12:17:12 PM:   Netlify Build                                                 
12:17:12 PM: ────────────────────────────────────────────────────────────────
12:17:12 PM: ​
12:17:12 PM: ❯ Version
12:17:12 PM:   @netlify/build 27.4.2
12:17:12 PM: ​
12:17:12 PM: ❯ Flags
12:17:12 PM:   baseRelDir: true
12:17:12 PM:   buildId: 62dacd7c53a5670008e76789
12:17:12 PM:   deployId: 62dacd7c53a5670008e7678b
12:17:12 PM: ​
12:17:12 PM: ❯ Current directory
12:17:12 PM:   /opt/build/repo
12:17:12 PM: ​
12:17:12 PM: ❯ Config file
12:17:12 PM:   No config file was defined: using default values.
12:17:12 PM: ​
12:17:12 PM: ❯ Context
12:17:12 PM:   branch-deploy
12:17:12 PM: ​
12:17:12 PM: ────────────────────────────────────────────────────────────────
12:17:12 PM:   1. Build command from Netlify app                             
12:17:12 PM: ────────────────────────────────────────────────────────────────
12:17:12 PM: ​
12:17:12 PM: $ npm run build-web
12:17:12 PM: > sanity-gridsome@1.0.4 build-web /opt/build/repo
12:17:12 PM: > lerna bootstrap && (cd studio && SANITY_AUTH_TOKEN=$SANITY_DEPLOY_STUDIO_TOKEN npm run graphql-deploy) && (cd web && npm run build)
12:17:12 PM: lerna notice cli v3.22.1
12:17:12 PM: lerna info ci enabled
12:17:12 PM: lerna info Bootstrapping 2 packages
12:17:12 PM: lerna info Installing external dependencies
12:17:57 PM: lerna info Symlinking packages and binaries
12:17:57 PM: lerna success Bootstrapped 2 packages
12:17:57 PM: > sanity-gridsome-studio@1.0.5 graphql-deploy /opt/build/repo/studio
12:17:57 PM: > sanity graphql deploy --playground
12:17:58 PM: Dataset: staging
12:17:58 PM: Tag: default
12:17:59 PM: Browserslist: caniuse-lite is outdated. Please run:
12:17:59 PM:   npx browserslist@latest --update-db
12:17:59 PM:   Why you should do it regularly: https://github.com/browserslist/browserslist#browsers-data-updating
12:18:03 PM: GraphQL API deployed to:
12:18:03 PM: https://xxxxxxxxxx.api.sanity.io/v1/graphql/staging/default
12:18:03 PM: > sanity-gridsome-web@ build /opt/build/repo/web
12:18:03 PM: > gridsome build
12:18:04 PM: Gridsome v0.7.23
12:18:04 PM: Initializing plugins...
12:18:05 PM: Load sources - 0.86s
12:18:05 PM: Create GraphQL schema - 0.28s
12:18:05 PM: Create pages and templates - 0.13s
12:18:05 PM: Generate temporary code - 0.05s
12:18:05 PM: Bootstrap finish - 1.86s
12:18:05 PM: Compiling assets...
12:18:25 PM: Compile assets - 19.35s
12:18:25 PM: Execute GraphQL (44 queries) - 0.09s
12:18:26 PM: Using the Sanity client without specifying an API version is deprecated. See https://docs.sanity.io/help/js-client-api-version
12:18:26 PM: Render HTML (44 files) - 1.61s
12:18:26 PM: Process files (0 files) - 0s
12:18:28 PM: Processing images (14 images) - 0%Processing images (14 images) - 100%Process images (14 images) - 1.1s
12:18:28 PM:   Done in 24.07s
12:18:28 PM: ​
12:18:28 PM: (build.command completed in 1m 16.3s)
12:18:28 PM: ​
12:18:28 PM: ────────────────────────────────────────────────────────────────
12:18:28 PM:   2. Deploy site                                                
12:18:28 PM: ────────────────────────────────────────────────────────────────
12:18:28 PM: ​
12:18:28 PM: Starting to deploy site from 'web/dist'
12:18:28 PM: Creating deploy tree 
12:18:28 PM: Creating deploy upload records
12:18:29 PM: 0 new files to upload
12:18:29 PM: 0 new functions to upload
12:18:29 PM: Site deploy was successfully initiated
12:18:29 PM: ​
12:18:29 PM: (Deploy site completed in 250ms)
12:18:29 PM: ​
12:18:29 PM: ────────────────────────────────────────────────────────────────
12:18:29 PM:   Netlify Build Complete                                        
12:18:29 PM: ────────────────────────────────────────────────────────────────
12:18:29 PM: ​
12:18:29 PM: (Netlify Build completed in 1m 16.6s)
12:18:29 PM: Starting post processing
12:18:29 PM: Post processing - HTML
12:18:29 PM: Caching artifacts
12:18:29 PM: Started saving node modules
12:18:29 PM: Finished saving node modules
12:18:29 PM: Started saving build plugins
12:18:29 PM: Finished saving build plugins
12:18:29 PM: Started saving pip cache
12:18:29 PM: Finished saving pip cache
12:18:29 PM: Started saving emacs cask dependencies
12:18:29 PM: Finished saving emacs cask dependencies
12:18:29 PM: Started saving maven dependencies
12:18:29 PM: Finished saving maven dependencies
12:18:29 PM: Started saving boot dependencies
12:18:29 PM: Processing form - Footer Newsletter
12:18:29 PM: Finished saving boot dependencies
12:18:29 PM: Started saving rust rustup cache
12:18:29 PM: Finished saving rust rustup cache
12:18:29 PM: Started saving go dependencies
12:18:29 PM: Finished saving go dependencies
12:18:29 PM: Build script success
12:18:29 PM: Detected form fields: - bot-field - email
12:18:29 PM: Processing form - cta
12:18:29 PM: Detected form fields: - bot-field - email
12:18:29 PM: Processing form - Info / Fale
12:18:30 PM: Detected form fields: - bot-field - name - email - message
12:18:30 PM: Processing form - Work / Trabalhe
12:18:30 PM: Detected form fields: - bot-field - name - email - message - file
12:18:30 PM: Post processing - header rules
12:18:30 PM: Post processing - redirect rules
12:18:30 PM: Post processing done
12:18:34 PM: Uploading Cache of size 108.9MB
12:18:34 PM: Finished processing build request in 1m32.59816554s
12:18:34 PM: Site is live ✨

Content as saved to the staging dataset:

Content as displayed on the staging front-end after numerous builds:

I have this same config actively working on a number of other sites being deployed to Netlify. The fact that the staging dataset has been indicated in the build logs is the biggest headscratcher of all.

Any suggestions at all would be greatly appreciated!

-Zack

Hi @zacklerner,

Something is wrong with your netlify.toml as that’s not being used:

https://app.netlify.com/sites/phil-young/deploys/62db15945d28280008347284#L56

We’re not detecting any netlify.toml for your site. Where in your repo does it exist?

1 Like

@hrishikesh That was it! Thanks so much for the quick reply.

The project is a monorepo and I now realize it actually needs two netlify.toml files. I’m also now seeing the the build logs indicate whether or not a config file has been defined.

Thanks again for your help!

1 Like