Skip to content

Failure to parse theme.json should be a lot more obvious #32009

@bobbingwide

Description

@bobbingwide

Description

A theme’s global styles are defined in a file called theme.json.

It’s a complicated file in JavaScript Object Notation (JSON ) format.

There are many settings which can have lots of values.

  • You have to get the structure and the syntax correct.
  • If you make any mistake with the syntax then the Global Styles aren’t set.
  • You don’t get any messages.
  • Everything just looks all wrong.
  • If you do make any changes, use a JSON validator to check your syntax.
  • And then check it again for semantics.

You don’t get any messages.

Well, something may be logged to PHP error log.

[19-May-2021 17:06:24 UTC] Error when decoding file schema: Syntax error

Step-by-step reproduction instructions

  1. Install and activate an FSE theme such as TT1 blocks
  2. Edit site
  3. View Global Styles
  4. Delete the first character from theme.json
  5. Edit site
  6. View Global Styles
  7. Notice the difference

Expected behaviour

The fact that theme.json could not be parsed should be made immediately obvious to the user.
This is going to happen an awful lot in the next few months.
The ability to perform problem determination needs to be significantly improved.

Actual behaviour

It just looks awful.

Screenshots or screen recording (optional)

Screen capture after step 3.
image

Screen capture after breaking theme.json in step 4.
image

Code snippet (optional)

WordPress information

  • WordPress version: 5.7.2
  • Gutenberg version: 10.6.0
  • Are all plugins except Gutenberg deactivated? Yes
  • Are you using a default theme (e.g. Twenty Twenty-One)? TT1 blocks

Device information

  • Device: Desktop
  • Operating system: Windows
  • Browser: Chrome

Metadata

Metadata

Labels

Global StylesAnything related to the broader Global Styles efforts, including Styles Engine and theme.json[Feature] ThemesQuestions or issues with incorporating or styling blocks in a theme.[Status] In ProgressTracking issues with work in progress[Type] FeedbackIssues that relate purely to feedback on a feature that isn't necessarily actionable

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions