Cannot read theme files with role "DEMO"

It seems that it is not possible to read/write themes that have role “DEMO” to avoid copying paid themes files for free.

Why do you need to be able to read/write theme files that you don’t own anyway?

Currently you can only check if an theme app extension is active, by reading config/settings_data.json

Having access to this file is also important during automated tests, because we can sync an theme app extension configuration across multiple themes in seconds.

Won’t this enable people to steal themes?

No because config/settings_data.json is a file required to be present in all themes and to have the same structure.

How to replicate what you’re describing?

  1. Go to the theme store: Ecommerce Website Templates - Free and Premium Themes for Your Online Store.
  2. Try a theme you do not own
  3. Run this query:
query DemoTheme {
  themes(first: 1, roles: [DEMO]) {
    nodes {
      id
      name
      files(filenames: ["config/settings_data.json"], first: 1) {
        nodes {
          body {
            ... on OnlineStoreThemeFileBodyText {
              __typename
            }
          }
        }
      }
    }
  }
}
  1. You should see this response:
{
  "errors": [
    {
      "message": "Access denied",
      "locations": [
        {
          "line": 6,
          "column": 7
        }
      ],
      "path": [
        "themes",
        "nodes",
        0,
        "files"
      ],
      "extensions": {
        "code": "ACCESS_DENIED",
        "documentation": "https://shopify.dev/api/usage/access-scopes"
      }
    }
  ],
  "data": {
    "themes": {
      "nodes": [
        {
          "id": "gid://shopify/OnlineStoreTheme/143571910818",
          "name": "Lollipop",
          "files": null
        }
      ]
    }
  },
  "extensions": {
    "cost": {
      "requestedQueryCost": 6,
      "actualQueryCost": 5,
      "throttleStatus": {
        "maximumAvailable": 2000,
        "currentlyAvailable": 1995,
        "restoreRate": 100
      }
    }
  }
}
1 Like

Hey @David_Arbias,

This is expected behavior. To test theme app extensions and access theme files programmatically, you’ll need to purchase the theme first. Demo themes are specifically intended for merchants to preview the visual design and functionality, not for app development or testing scenarios.

Once purchased, the theme will have full file access permissions that allow your automation scripts to read settings_data.json and other theme files as expected.

Well that’s sad because a lot of users preview a trial theme then try to test with theme app extensions.

If the app doesn’t indicate the theme app extension is activated, they will assume the theme is not compatible with the app that they like, and Shopify will potentially lose the 15% comission from the theme sale.

That’s a good point. Have you found merchants uninstalling your app due to this? One thought to address this could be to add a note in your app UI when you can’t read a theme file, to pass on this context.