Ghost
Ghost copied to clipboard
Author slug with one letter causes failed filter
Issue Summary
A staff member that signs up with a single-letter first name upon invitation will not be able to use Ghost at all. They only see an error message in the Ghost admin:
Request not understood error, cannot list posts. Error parsing filter
Looking at the network requests, the request to /ghost/api/admin/posts/?formats=mobiledoc%2Clexical&limit=30&page=1&filter=status%3A%5Bdraft%2Cscheduled%2Cpublished%2Csent%5D%2Bauthors%3Aj
fails.
As soon as the last filter is removed, the API request succeeds:
https://tireless-buzzard.pikapod.net/ghost/api/admin/posts/?formats=mobiledoc%2Clexical&limit=30&page=1&filter=status%3A%5Bdraft%2Cscheduled%2Cpublished%2Csent%5D
I have then tried to change the author slug in the database from "j" to "jb" – and things started to work.
This has been tested in different environments, both locally with development configurations, as well as on different managed hosts. Ghost v5.82.2 and v5.82.6 have been tested, both from the CLI as well as Docker images.
Steps to Reproduce
- Invite a new staff member as contributor
- Accept the invitation and register – IMPORTANT: Set the name to have a single-letter first name, e.g. "J Doe" instead of "John Doe"
- See the error
Ghost Version
v5.82.6
Node.js Version
18 LTS
How did you install Ghost?
Ghost CLI
Database type
MySQL 8
Browser & OS version
Mac OS 14.4.1, latest Chrome and latest Safari tested
Relevant log / error output
[2024-05-05 16:55:19] ERROR "GET /ghost/api/admin/posts/?formats=mobiledoc%2Clexical&limit=30&page=1&filter=status%3A%5Bdraft%2Cscheduled%2Cpublished%2Csent%5D%2Bauthors%3Aj" 400 12ms
Error parsing filter
Error ID:
415527a0-0b00-11ef-96dc-2bc1b8db7476
----------------------------------------
Error: Query Error: unrecognized text "j" in filter at char 24
at Child.applyDefaultAndCustomFilters (/var/lib/ghost/versions/5.82.2/node_modules/@tryghost/bookshelf-filter/lib/bookshelf-filter.js:66:23)
...ished,sent]+authors:j)+type:post
-----------------------^
at lexer.parseError (/var/lib/ghost/versions/5.82.2/node_modules/@tryghost/nql-lang/dist/parser.js:760:11)
at Object.next (/var/lib/ghost/versions/5.82.2/node_modules/@tryghost/nql-lang/dist/parser.js:625:25)
at Object.lex (/var/lib/ghost/versions/5.82.2/node_modules/@tryghost/nql-lang/dist/parser.js:635:22)
at lex (/var/lib/ghost/versions/5.82.2/node_modules/@tryghost/nql-lang/dist/parser.js:246:27)
at Parser.parse (/var/lib/ghost/versions/5.82.2/node_modules/@tryghost/nql-lang/dist/parser.js:259:26)
at exports.parse (/var/lib/ghost/versions/5.82.2/node_modules/@tryghost/nql-lang/lib/nql.js:18:44)
at api.parse (/var/lib/ghost/versions/5.82.2/node_modules/@tryghost/nql/lib/nql.js:15:31)
at api.querySQL (/var/lib/ghost/versions/5.82.2/node_modules/@tryghost/nql/lib/nql.js:49:44)
at Builder.<anonymous> (/var/lib/ghost/versions/5.82.2/node_modules/@tryghost/bookshelf-filter/lib/bookshelf-filter.js:63:24)
at Object.query (/var/lib/ghost/versions/5.82.2/node_modules/bookshelf/lib/helpers.js:164:14)
at Child.query (/var/lib/ghost/versions/5.82.2/node_modules/bookshelf/lib/model.js:1387:22)
at Child.applyDefaultAndCustomFilters (/var/lib/ghost/versions/5.82.2/node_modules/@tryghost/bookshelf-filter/lib/bookshelf-filter.js:56:22)
at Function.getFilteredCollection (/var/lib/ghost/versions/5.82.2/core/server/models/base/plugins/filtered-collection.js:13:32)
at Function.findPage (/var/lib/ghost/versions/5.82.2/core/server/models/base/plugins/crud.js:83:41)
at PostsService.browsePosts (/var/lib/ghost/versions/5.82.2/node_modules/@tryghost/posts-service/lib/PostsService.js:81:44)
at Object.query (/var/lib/ghost/versions/5.82.2/core/server/api/endpoints/posts.js:73:33)
Code of Conduct
- [X] I agree to be friendly and polite to people in this repository
Hey, I am Tanu sharma having 2 year of exp in SDE field can I take this issue?
Can confirm with current Ghost(Pro) trial; disagree somewhat with the 'low' categorization. It's stressful to a new user as the error message is so unrelated as to cause general alarm of having broken everything :). Once the cause is known (thanks for submitting this issue!), it can be resolved easily for the existing user.