0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-03 23:00:14 -05:00

Updated error messages for invalid mobiledoc+lexical post/page API requests (#15477)

closes https://github.com/TryGhost/Team/issues/1896

- updated message to be clearer, added context and help
This commit is contained in:
Kevin Ansfield 2022-09-27 10:30:28 +01:00 committed by GitHub
parent d3030cb87d
commit 89d4e3daf9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 5 deletions

View file

@ -5,7 +5,9 @@ const tpl = require('@tryghost/tpl');
const messages = {
invalidVisibilityFilter: 'Invalid filter in visibility_filter property',
onlySingleContentSource: 'It\'s only possible to save mobiledoc or lexical properties, not both'
onlySingleContentSource: 'Pages can have either a mobiledoc or a lexical property, never both.',
onlySingleContentSourceContext: 'Both the mobiledoc and lexical properties are set, one must be null',
onlySingleContentSourceHelp: 'https://ghost.org/docs/admin-api/#the-post-object'
};
const validateVisibility = async function (frame) {
@ -43,6 +45,8 @@ const validateSingleContentSource = async function (frame) {
if (page.mobiledoc && page.lexical) {
return Promise.reject(new ValidationError({
message: tpl(messages.onlySingleContentSource),
context: tpl(messages.onlySingleContentSourceContext),
help: tpl(messages.onlySingleContentSourceHelp),
property: 'lexical'
}));
}

View file

@ -5,7 +5,9 @@ const tpl = require('@tryghost/tpl');
const messages = {
invalidVisibilityFilter: 'Invalid filter in visibility_filter property',
onlySingleContentSource: 'It\'s only possible to save mobiledoc or lexical properties, not both'
onlySingleContentSource: 'Posts can have either a mobiledoc or a lexical property, never both.',
onlySingleContentSourceContext: 'Both the mobiledoc and lexical properties are set, one must be null',
onlySingleContentSourceHelp: 'https://ghost.org/docs/admin-api/#the-post-object'
};
const validateVisibility = async function (frame) {
@ -43,6 +45,8 @@ const validateSingleContentSource = async function (frame) {
if (post.mobiledoc && post.lexical) {
return Promise.reject(new ValidationError({
message: tpl(messages.onlySingleContentSource),
context: tpl(messages.onlySingleContentSourceContext),
help: tpl(messages.onlySingleContentSourceHelp),
property: 'lexical'
}));
}

View file

@ -427,10 +427,10 @@ Object {
"errors": Array [
Object {
"code": null,
"context": "It's only possible to save mobiledoc or lexical properties, not both",
"context": "Posts can have either a mobiledoc or a lexical property, never both. Both the mobiledoc and lexical properties are set, one must be null",
"details": null,
"ghostErrorCode": null,
"help": null,
"help": "https://ghost.org/docs/admin-api/#the-post-object",
"id": StringMatching /\\[a-f0-9\\]\\{8\\}-\\[a-f0-9\\]\\{4\\}-\\[a-f0-9\\]\\{4\\}-\\[a-f0-9\\]\\{4\\}-\\[a-f0-9\\]\\{12\\}/,
"message": "Validation error, cannot save post.",
"property": "lexical",
@ -444,7 +444,7 @@ exports[`Posts API Create Errors if both mobiledoc and lexical are present 2: [h
Object {
"access-control-allow-origin": "http://127.0.0.1:2369",
"cache-control": "no-cache, private, no-store, must-revalidate, max-stale=0, post-check=0, pre-check=0",
"content-length": "294",
"content-length": "409",
"content-type": "application/json; charset=utf-8",
"etag": StringMatching /\\(\\?:W\\\\/\\)\\?"\\(\\?:\\[ !#-\\\\x7E\\\\x80-\\\\xFF\\]\\*\\|\\\\r\\\\n\\[\\\\t \\]\\|\\\\\\\\\\.\\)\\*"/,
"vary": "Origin, Accept-Encoding",