Builds suddenly failing with 500 errors

Hi, our builds are suddenly failing with 500 errors. I've been trying to track down the cause but it seems nothing has changed in our codebase recently.

I looked through the prismic documentation and I can't find a reference to xxx.cdn.prismic.io endpoints anymore, but changing it to xxx.prismic.io within our sm.json doesn't seem to stop it being called, which makes me wonder whether we have an outdated package that is making this call.

I've removed the public key from the call below. If you need it I can send it to you privately.

Thanks

Error: Error: Unexpected status code [500] on URL https://pila.cdn.prismic.io/api/v2/documents/search?page=1&pageSize=20&routes=%5B%7B%22type%22%3A%22home%22%2C%22path%22%3A%22%2F%22%7D%2C%7B%22type%22%3A%22theme_page%22%2C%22path%22%3A%22%2F%3Auid%22%7D%2C%7B%22type%22%3A%22learning_module_home%22%2C%22path%22%3A%22%2Flearning_modules%22%7D%2C%7B%22type%22%3A%22learning_module%22%2C%22path%22%3A%22%2F%3Aparent%2F%3Auid%22%2C%22resolvers%22%3A%7B%22parent%22%3A%22parent%22%7D%7D%2C%7B%22type%22%3A%22assessment_application%22%2C%22path%22%3A%22%2F%3Aparent%2F%3Amodule%2F%3Auid%22%2C%22resolvers%22%3A%7B%22module%22%3A%22module%22%2C%22parent%22%3A%22module.parent%22%7D%7D%2C%7B%22type%22%3A%22detail_page%22%2C%22path%22%3A%22%2F%3Aparent%2F%3Auid%22%2C%22resolvers%22%3A%7B%22parent%22%3A%22parent%22%7D%7D%2C%7B%22type%22%3A%22guide_home%22%2C%22path%22%3A%22%2Fguides%22%7D%2C%7B%22type%22%3A%22guide%22%2C%22path%22%3A%22%2Fguides%2F%3Auid%22%7D%2C%7B%22type%22%3A%22form%22%2C%22path%22%3A%22%2Fcontact%22%7D%2C%7B%22type%22%3A%22sessions%22%2C%22path%22%3A%22%2Faccount%2Fsessions%22%7D%5D&ref=YjRXBRAAACMAv0Af&q=%5B%5Bin(document.id%2C%20%5B%22YCZWKREAAI5deynI%22%2C%22YDjtUhEAACQAVSfd%22%2C%XXXXXXXXXXX%22%5D)%5D%5D

Hi @daveymoores,

Thanks for reaching out.

Actually, the CDN is necessary in all cases and shouldn't cause an issue, but can you please tell us how often you get this error and what is the technology/framework used.

Also, I would like to confirm; is pila is the repository name you are using and having errors related to? If not, can you please send us the repository name (in a private message if necessary) to check if we have any errors on our side?

Hi Fares,

Yep, pila is the repository name and It's a Next.js project. I just triggered a build and I'm getting the same error.

I've sent through the full error on a private message.

Thanks for your help.

1 Like

Ok, @daveymoores,

Thanks for the info, I haven't got the private message can you send it again to me

I will check tomorrow and let you know.

I've looked at the logs related to your repository, and there seem no recent errors happening, and it seems that those errors are on your end.

Are you using a proxy in your network?

Also, if you can share with us a zip file with your project code (in a private message if necessary) to try to reproduce the issue on our end, it will be really helpful.

I've messaged Fares directly with some new findings but I see he is on holiday.

Is anyone else able to help me and pick this up?

Thanks, D

Hello @daveymoores

Fares is out of the office the whole of this week. So far, I found that you have some issues in routes learning_module and assessment_application. I am trying to debug it more and return it to you as I find something.

I have one question for you:
Are you able to run your project locally because I get an error when I run locally?

And on console it shows: at Function.PilaApp.getInitialProps (webpack-internal:///./pages/_app.tsx:218:11)

Thanks,
Priyanka

Hi Priyanka,

Sorry I was away for a few days.

Yes that is the error I'm facing. When the project builds it fetches a bunch of data for all the routes in _app.tsx. It's there i'm getting the 500 error you have shown above. I sent Fares some of findings. Are you able to access his direct messages?

Thanks,
D

Hello, @daveymoores/ We have received your message. Fares will review the information as soon as possible. Thank you

Great, thanks @Pau

1 Like

You're welcome.

Hi Pau,

Any developments on this?

Thanks,
D

Hi @daveymoores,
I was off for a few days, I'm currently building your project locally and trying to reproduce the issue on my side to be able to debug the issue, and I will let you know about my finding as soon as possible.

Thanks Fares.

Hi @daveymoores,

I'm still investigating this; this error usually means that you have written the resolver incorrectly or have documents in that list without the content relationship selected (I've checked your repo, and it doesn't seem to be the case).

I will let you know as soon as we have any updates.

Hi @daveymoores,

I've got some updates about this issue from our dev team, and we think that this is the cause of the problem:

module.parent links to learning_module_home which appears to be a singleton without UID: https://pila.cdn.prismic.io/api/v2/documents/search?page=1&pageSize=20&ref=YjRXBRAAACM[…]ny(document.type,%20%5B%22learning_module_home%22%5D)%5D%5D

and here are some potential solutions:

  • Adding a UID field to learning_module_home with a value of "learning-modules"

I've tested that and it works see the following screenshot:

  • Or updating your route resolver rules for assessment_application document type to:

{ type: "assessment_application", path: "/learning-modules/:module/:uid", resolvers: { module: "module", }, }

Please let us know if you need any further assistance,
Fares

Thanks Fares,

I’m on holiday but will see if someone else from the team can give this a go, otherwise I’ll make these changes on Monday and update this thread.

Thanks,
D

1 Like

Thanks Fares, our builds are now passing. It's strange how this randomly started failing without any code changes :man_shrugging: but at least it's all working correctly :tada:

1 Like