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

Unpublished page causes a Gatsby build error #19

Open
steveshaddick opened this issue May 6, 2021 · 9 comments
Open

Unpublished page causes a Gatsby build error #19

steveshaddick opened this issue May 6, 2021 · 9 comments

Comments

@steveshaddick
Copy link

This sounds extremely similar to issue #8, however we can see explicit error messaging.

We are using Agility CMS, with Gatsby v2.32, gatsby-source-agilitycms v1.6.6, deploying with Gatsby Cloud to Netlify. We have set up the site according to Agility Gatsby CMS Starter instructions. I realize these are not the latest versions, but looking at the changelogs I can't see that this should be a reason for this error.

There is an unpublished page in Agility. The Gatsby Cloud build fails completely suring Building static HTML for pages because of a null reference to data.agilitypage within the data coming into the master page template (AgilityPage.js).

Why is gatsby-source-agilitycms sourcing unpublished pages from Agility? How can this be avoided?

@joelvarty
Copy link
Member

Unpublished pages should NOT be coming through with your production mode builds. The first thing I would check is that you aren't sourcing content in preview mode (ie: make sure you're using the Fetch API Key and AGILITY_API_ISPREVIEW=false).

I would get that setup locally and test with gatsby clean, gatsby build, gatsby serve

@steveshaddick
Copy link
Author

ah thanks for the quick response - to be clear, this is in the preview mode. It's the CMS Preview build that fails and brings down the CMS Preview site.

In local development, the build starts up fine, and the site works normally other than when visiting the unpublished page route where it throws an error.

@joelvarty
Copy link
Member

If you can show us the error you're getting the CMS Preview on Gatsby Cloud it might help. @joshua-isaac - tagging you on this in case you recognize anything.

@steveshaddick
Copy link
Author

steveshaddick commented May 6, 2021

Sure thing, here's a dump of the build log.

15:32:10 PM:
Node version v12.22.1

15:32:11 PM:
Gatsby version Gatsby CLI version: 2.19.0

15:32:11 PM:
Gatsby version: 2.32.0

15:32:11 PM:
  Note: this is the Gatsby version for the site at: /usr/src/app/www

15:32:11 PM:
INCREMENTAL_PREVIEWS

15:32:11 PM:
Setting gatsby to /usr/src/app/www/node_modules/gatsby

15:32:12 PM:
info Running Inc Build CLI v0.7.0

15:32:13 PM:
verbose 2.024097738 making initial clean build

15:32:14 PM:
success open and validate gatsby-configs - 0.046s

15:32:14 PM:
success load plugins - 0.365s

15:32:14 PM:
success onPreInit - 0.026s

15:32:14 PM:
success delete html and css files from previous builds - 0.044s

15:32:14 PM:
success initialize cache - 0.005s

15:32:14 PM:
success copy gatsby files - 0.061s

15:32:14 PM:
success onPreBootstrap - 0.020s

15:32:14 PM:
success createSchemaCustomization - 0.005s

15:32:14 PM:
AgilityCMS => Source Nodes Started (production)... 

15:32:15 PM:
AgilityCMS => Starting Sync for en-ca - preview mode. 

15:32:15 PM:
AgilityCMS => Touched 19854 nodes 

15:32:15 PM:
AgilityCMS => Content Sync returned no item(s). 

15:32:15 PM:
AgilityCMS => Page Sync returned 1 item(s). 

15:32:15 PM:
AgilityCMS => Updating Sitemap channel corporatev2 in en-ca 

15:32:15 PM:
AgilityCMS => Completed Sync for en-ca - preview mode. 

15:32:15 PM:
AgilityCMS => Starting Sync for fr-ca - preview mode. 

15:32:15 PM:
AgilityCMS => Content Sync returned 3 item(s). 

15:32:15 PM:
AgilityCMS => Page Sync returned 1 item(s). 

15:32:15 PM:
AgilityCMS => Updating Sitemap channel corporatev2 in fr-ca 

15:32:16 PM:
AgilityCMS => Completed Sync for fr-ca - preview mode. 

15:32:16 PM:
AgilityCMS => Creating sitemap nodes... 

15:32:16 PM:
AgilityCMS => Source Nodes Completed. 

15:32:16 PM:
verbose 4.290453347 Deleted 0 pages

15:32:16 PM:
verbose 4.289885141 Checking for deleted pages

15:32:16 PM:
verbose 4.290565156 Found 0 changed pages

15:32:16 PM:
success Checking for changed pages - 0.001s

15:32:16 PM:
success source and transform nodes - 1.441s

15:32:21 PM:
success building schema - 4.971s

15:32:21 PM:
AgilityCMS => Create Pages Started... 

15:32:21 PM:
AgilityCMS => Homepage requests to /en-ca/Home will redirect to '/en-ca/' 

15:32:21 PM:
AgilityCMS => Root requests to '/' will redirect to the default language path '/en-ca/' 

15:32:21 PM:
AgilityCMS => 220 pages created from corporatev2 in en-ca 

15:32:21 PM:
AgilityCMS => Homepage requests to /fr-ca/accueil will redirect to '/fr-ca/' 

15:32:21 PM:
AgilityCMS => 207 pages created from corporatev2 in fr-ca 

15:32:21 PM:
info Total nodes: 20754, SitePage nodes: 856 (use --verbose for breakdown)

15:32:21 PM:
success createPages - 0.405s

15:32:21 PM:
verbose 9.669752432 Checking for deleted pages

15:32:21 PM:
verbose 9.670631727 Found 855 changed pages

15:32:21 PM:
verbose 9.670067701 Deleted 0 pages

15:32:21 PM:
success Checking for changed pages - 0.001s

15:32:21 PM:
success createPagesStatefully - 0.054s

15:32:21 PM:
success Cleaning up stale page-data - 0.036s

15:32:21 PM:
success update schema - 0.310s

15:32:21 PM:
success onPreExtractQueries - 0.000s

15:32:22 PM:
success extract queries from components - 0.650s

15:32:22 PM:
success write out redirect data - 0.003s

15:32:22 PM:
info bootstrap finished - 10.732s

15:32:22 PM:
success onPostBootstrap - 0.001s

15:32:22 PM:
success run static queries - 0.125s - 2/2 15.95/s

15:32:24 PM:
success run page queries - 2.015s - 430/430 213.40/s

15:32:24 PM:
success write out requires - 0.022s

15:32:32 PM:
success Building production JavaScript and CSS bundles - 7.788s

15:32:32 PM:
success Rewriting compilation hashes - 0.008s

15:32:36 PM:
success Building HTML renderer - 2.824s

15:32:37 PM:
failed Building static HTML for pages - 1.207s

15:32:37 PM:
ERROR Building static HTML failed for path "/en-ca/pa-toolkit"

15:32:37 PM:
  13 |

15:32:37 PM:
  12 |   })

15:32:37 PM:
> 14 |   const page = JSON.parse(data.agilitypage.pageJson)

15:32:37 PM:
  17 |     //replace the title with the title of the post

15:32:37 PM:
     |                                            ^

15:32:37 PM:
  16 |   if (dynamicPageItem) {

15:32:37 PM:
  15 |

15:32:37 PM:
15:32:37 PM:
    src/agility/utils.js:14:44

15:32:37 PM:
  WebpackError: TypeError: Cannot read property 'pageJson' of null

15:32:37 PM:
  

15:32:37 PM:
  - utils.js:14 

15:32:37 PM:
  - AgilityPage.js:187 

15:32:37 PM:
    src/AgilityPage.js:187:34

15:32:37 PM:
  

15:32:37 PM:
  

15:32:37 PM:
15:32:38 PM:
ERROR Failed to compile: Error: Exited with code 1

@joelvarty
Copy link
Member

Thanks! No doubt that's a bug - @joshua-isaac can you take a look? We may have fixed this already in V3, but it's worth a look to see if we need to patch that.

@joshua-isaac
Copy link
Contributor

hello @steveshaddick, thanks for reporting this!

after testing on our end we can confirm this is a bug, i've created an internal ticket to get this fixed.

unfortunately, the only workaround as of now would be to delete the unpublished page :(

i can follow up with you as soon as this issue gets resolved.

@steveshaddick
Copy link
Author

thanks very much @joshua-isaac , I'll see about deleting the page. I'm sure you don't have a clear idea exactly when the bug might be resolved, but might it be within a week or two, or should we expect longer than that?

@joshua-isaac
Copy link
Contributor

hi @steveshaddick, just wanted to follow up.

we've identified the root cause of the issue here and should have someone working on the ticket to resolve the problem next week.

again, will follow up with you :)

thanks!

@steveshaddick
Copy link
Author

thanks @joshua-isaac - I have a followup, actually, that may or may not be related. If it is not related, I can make a new issue thread.

In the preview site, we have a blog index page that shows recent blog articles. Its data source is from the graphql query allAgilityComponentBlogPost. On the preview site, this data seems to include posts that are deleted and sitting in the Recycle Bin. Meaning, on the preview site, deleted posts are appearing in the blog index page list.

Is this the same issue?

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