TLDR: In spite of errors, files should still always be uploaded, failing to create files because of schema errors causes themes to be way more broken and is a bigger problem
My team and I are running into an issue pretty often now where a theme is live and working, but when we go into dev mode or create a new Github connected theme with the same exact code a bunch of sections and templates aren’t uploaded because they were considered invalid due to schema errors. I believe there was a recent change which made this issue more common.
It seems like if the file gets into an error state after it was made or if you use the CLI to push the files are created or updated without failing. When templates or sections exist in a theme with schema errors, just those particular chunks of the schema or sections in a template just don’t get rendered or the issue is effectively ignored and the rest of the file still works. But in the CLI when you’re uploading files or through Github integration it will just cause the entire file to not be uploaded, causing other files that are dependent on it to not be uploaded as well and this can result in completely broken pages and a very broken site.
I’ve also created this issue in the shopify CLI repo [Feature]: Schema errors results in the file not being uploaded at all · Issue #6315 · Shopify/cli · GitHub
So if this is understood (probably not), you want the CLI to successfully upload files that break the schema.
OK. So two things. One, the CLI lets files that break schema go, and that would make everyone happy, except the files violate correctness. Or, two, the whole shooting match is banned from upload, because broken schema files. Fix, or no uploads.
As it stands, it has worked to date by allowing all files to upload, broken or not. So continue and carry on, instead of just not uploading files that violate correct?
Is this correct?
Almost all of the schema errors I run into don’t completely break the schema. So yes, I want the file to still be uploaded because usually it will still mostly work.
For example, yesterday I ran into a theme which had multiple sections that weren’t uploaded because the new “visible_if“ property was used on setting types that can’t use visible_if. Because these sections weren’t created, all templates that use these sections also weren’t created - resulting in many broken pages and a new theme that did not match the code in my repo. However, on the live site, which also had the exact same code, the sections existed and still worked. The visible if property just didn’t do anything. The file existing in a semi-broken state is very preferable to it not existing at all.
I would like files to be uploaded whether they are broken or not. Errors should still be shown to the user in the CLI or in the GitHub integration logs. When I use the integration or the CLI, I expect files to be recreated and uploaded exactly as I have them in my repo. Validation of schema should be a layer on top of this, not something that will prevent the uploading of files.
Interesting. One can see how this is a tough issue to solve to satisfaction. It is not the only example of this kind of blooper either. There exist many similar gotchas, none of which are an actual bug, but instead, they exhibit how fragile this entire theme approach can be!