Skip to content

Inserting a Site Title block causes a 403 error (REST API) #33003

@ockham

Description

@ockham

Description

Found while working on #32868. This is currently blocking #32868, as it causes e2e tests to fail 😕

Repro'd on current GB trunk.

Step-by-step reproduction instructions

  1. Log into WP as a non-admin user (e.g. Editor role).
  2. Create a new post.
  3. Open your browser devtools bar (Network tab), and clear it.
  4. Insert a 'Site Title' block

Expected behaviour

No network request to fail with a 403.

Actual behaviour

The network request to GET http://localhost:8888/index.php?rest_route=%2Fwp%2Fv2%2Fsettings%2F&_locale=user comes back with a 403 error, with the following response:

{
	"code": "rest_forbidden",
	"message": "Sorry, you are not allowed to do that.",
	"data": { "status": 403 }
}

The error is also visible in the devtools console, including a stacktrace. While minimized, it seems to be caused by this line:

const [ title, setTitle ] = useEntityProp( 'root', 'site', 'title' );

Bonus

If you enter 'Site' into the block picker to locate the Site Title block, there's another network request that fails with a 403:

GET http://localhost:8888/index.php?rest_route=/wp/v2/users&context=edit&per_page=100&_locale=user fails with

{
	"code": "rest_forbidden_context",
	"message": "Sorry, you are not allowed to list users.",
	"data": { "status": 403 }
}

The stack trace points to the Query Loop block for this one:

authorList: getEntityRecords( 'root', 'user', {
per_page: -1,
} ),
.

This latter 403 also causes an Uncaught (in promise) error to be logged in the browser console.

cc/ @ntsekouras

Metadata

Metadata

Assignees

Labels

[Block] Query LoopAffects the Query Loop Block[Block] Site TitleAffects the Site Title Block[Status] In ProgressTracking issues with work in progress[Type] BugAn existing feature does not function as intended

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions