Error 422 - about.json does not exist when trying to run "discourse_theme watch

AI-generated summary

A user named hdng is encountering an Error 422 when running discourse_theme watch ., stating that about.json does not exist or is invalid — despite confirming the file’s presence, correct formatting, encoding, and directory structure. They’ve ruled out theme corruption by testing with a freshly generated theme via discourse_theme new. chapoi suggests verifying API key settings, specifically ensuring it’s global and assigned to a specific user — which hdng confirms they’ve already done, even testing with new keys tied to admin/moderator accounts. awesomerobot proposes checking the ~/.discourse_theme config file for malformed entries or escape characters, particularly if using bracketed paste mode in terminal emulators. hdng inspects the file and finds odd syntax (e.g., ! '':), cleans it up, but still experiences the same error. The issue remains unresolved, with suspicions pointing toward configuration file corruption or hidden terminal-related formatting issues, despite valid theme and API setup.

Hello,

Hoping someone might be able to help here.

For context, I’ve picked up the current forum from a previous agency and I’ve not worked in Discourse prior to this week.

I need to make a modification to the theme (to fix the id:discourse.component-template-resolving notice).

I’ve followed the guide to setting up the CLI. I’ve managed to connect to the API and download the theme files.

However, when I try to run discourse_theme watch . I’m getting the following error:

✘ Error 422 for https://forum.mywebsite.co.uk/admin/themes/import.json: Import Error: about.json does not exist, or is invalid. Are you sure this is a Discourse Theme?

I have checked the following:

  • I’m operating from the correct folder.
  • about.json is named and formatted correctly
    • I have authors and the version numbers in there too
    • The encoding is correct
  • All directories exist

I thought possibly it could be the API permissions, but if I’m connected and the scopes in admin/api/keys/settings are correct and present, then surely it can’t be?

Basically, I’m stuck. Please can someone point me in the right direction?

I remember something similar that was still an API problem: can you check the setting of your API key, it has to be set to global & set it to a specific user, not to all users.

Hi Charlie,

Thanks for the reply. The API key that I was using was already set to global and to a specific user.

However, I have created 2 new ones against some moderators/admins (just in case it didn’t like the current admin user) and I’m having the same results again.

Thanks :slight_smile:

Sorry just to update this, I’ve also created a brand new theme discourse_theme new <dir> and again it falls over when I run the watch command, so that rules out that there’s an issue with the theme (as you mentioned before)

Unfortunately, that’s the extend of my “how-to-run” things setup knowledge :sweat_smile:

I’m sure a more knowledgeable person will be able to help you out soon.

I’ve mainly seen that error when trying to run the command on a plugin (which won’t work) but you say it’s a theme, or with maybe formatting errors in the .json, but you’ve checked that already… :thinking:

Location may vary, but have you taken a look at your ~/.discourse_theme file?

I’ve run into an issue before where my terminal emulator was using “bracketed paste mode”

You can see the difference below (these aren’t real keys, I’ve truncated them for sharing)… if you see something like the first entry with escape characters, that’s incorrect and won’t work.

image

Hi Kris,

Thanks for the reply, I hadn’t thought of that!

I checked my discourse_theme file, and while the API key was formed properly, the file itself does look a bit malformed, compared to other examples I’ve seen (including yours).

Should be worth noting that I’m on macOS here and this was the result of cat ~/discourse_theme in iTerm.

"/Users/firstname.lastname/_dev/_dru/site-discourse-forum/src":
  url: https://forum.site.co.uk
  theme_id: 2
api_keys:
  ! '':
  https://forum.site.co.uk: [API_KEY]
"/Users/firstname.lastname/_dev/_dru/site-discourse-forum":
  url: https://forum.site.co.uk

I will proceed down the avenue of cleaning this up as this potentially could be a reason.

EDIT: Nope. Removed the ! ‘ ‘: and the second entry. Same thing. :melting_face: