Dato CMS Query Causing Build Error

Hello Support,

I’m using Dato CMS with Astro as the SSG and deploying to Netlify.

After following this guide: DatoCMS & Astro | Docs
I’ve connected Dato CMS with Astro and the text changes I’ve made in the CMS come through to the front end on the local version.

Next I set up the project to deploy through GitHub;

And the Netlify project is here;

Everything is great until I try to deploy and I get the attached build error.

The error message is saying the ‘title’ field from Dato CMS is possibly undefined or may not be in the correct file (index.astro). But I’ve checked this and ‘title’ is working on my local version.

I’ve been through the settings and it all looks good.

Any help would be greatly appreciated!

Thanks,

Richard Gill

PLEASE help us help you by writing a good post!

  • We need to know your netlify site name. Example: gifted-antelope-58b104.netlify.app
  • DNS issues? Tell us the custom domain, tell us the error message! We can’t help if we don’t know your domain.
  • Build problems? Link or paste the FULL build log & build settings screenshot
  • Did you try Ask Netlify, our generative AI chatbot, before posting? It pulls info from Support Guides and recent solved forums posts.

The better the post - the faster the answer.

@RichardGill The build log isn’t public:

If the error says a certain value is undefined, then it’s almost certainly undefined at that point in the build execution.

Try running your build locally (not develop mode, but the same build command as on Netlify).
You can use console.log to check values and confirm assumptions.

Hello @nathanmartin

Thanks for getting back to me.

I tried changing the Deploy log visibility as seen here in the docs;

But I don’t have the Deploy log visibility option in my build settings :slightly_frowning_face:

I’ve attached the error from the build log;

I also get the ‘title’ back locally when testing with console.log.

Any other suggestions would be great.

Thanks,

Richard Gill

@RichardGill You would need to provide the section of the build log containing the actual error, not the section you have screenshot.

(I actually have an open Feature Request regarding this: https://answers.netlify.com/t/error-message-command-failed-with-exit-code-is-confusing-misleading/118887)

Your site likely uses environment variables to connect to dato, and if that’s the case I won’t be able to test it myself. Have you made sure they’re set correctly on Netlify?

1 Like

I was missing the Environment Variable! Thanks so much for your help @nathanmartin :raised_hands::fireworks::sparkler: