[Bug Report]: Unable to upload attachments, get HTTP error 422 #2620

Closed
opened 2026-02-05 04:38:14 +03:00 by OVERLORD · 7 comments
Owner

Originally created by @Jcdiem on GitHub (Feb 1, 2022).

Describe the Bug

Whenever I go to upload an attachment I get the error 'Failed to load resource: the server responded with a status of 422 (Unprocessable Content)' in the web browser console. The app itself provides no error.
I have checked file permissions, the webserver has access to all of the folders used in uploading. Configurations for PHP and Nginx both have a max file size of 2048M.
I have also uploaded images and used them as book covers just fine.

Steps to Reproduce

  1. Create a book with a chapter and page.
  2. Edit the page and go to attachments
  3. Try to upload any file of any size
  4. 'X' png appears over upload with description text [object Object]
  5. Web console shows upload failed

Expected Behaviour

Expected file to upload to server without error.

Screenshots or Additional Context

Files tested: pdf, docx, txt, png, jpg

Exact BookStack Version

v21.12.3

PHP Version

7.4

Hosting Environment

Ubuntu 20.04.3 LTS with MariaDB, Nginx, and PHP 7.4

Originally created by @Jcdiem on GitHub (Feb 1, 2022). ### Describe the Bug Whenever I go to upload an attachment I get the error 'Failed to load resource: the server responded with a status of 422 (Unprocessable Content)' in the web browser console. The app itself provides no error. I have checked file permissions, the webserver has access to all of the folders used in uploading. Configurations for PHP and Nginx both have a max file size of 2048M. I have also uploaded images and used them as book covers just fine. ### Steps to Reproduce 1. Create a book with a chapter and page. 2. Edit the page and go to attachments 3. Try to upload any file of any size 4. 'X' png appears over upload with description text [object Object] 5. Web console shows upload failed ### Expected Behaviour Expected file to upload to server without error. ### Screenshots or Additional Context Files tested: pdf, docx, txt, png, jpg ### Exact BookStack Version v21.12.3 ### PHP Version 7.4 ### Hosting Environment Ubuntu 20.04.3 LTS with MariaDB, Nginx, and PHP 7.4
OVERLORD added the 🐛 Bug label 2026-02-05 04:38:14 +03:00
Author
Owner

@ssddanbrown commented on GitHub (Feb 1, 2022):

Hi @Jcdiem,
This does sound strange and I'm not sure how to reproduce.
The status code and description text indicates a validation issue. The only way I can think of triggering one here (In a normal context) is deleting the page in the background on another tab, then attempting an upload. Even then it causes a different error.

Would you be able to view & share the response content found when clicking on the failing request when you have the "Network" tab open in the browser dev tools? I'm thinking that should show some validation error messages.

@ssddanbrown commented on GitHub (Feb 1, 2022): Hi @Jcdiem, This does sound strange and I'm not sure how to reproduce. The status code and description text indicates a validation issue. The only way I can think of triggering one here (In a normal context) is deleting the page in the background on another tab, then attempting an upload. Even then it causes a different error. Would you be able to view & share the response content found when clicking on the failing request when you have the "Network" tab open in the browser dev tools? I'm thinking that should show some validation error messages.
Author
Owner

@Jcdiem commented on GitHub (Feb 1, 2022):

The response returned was {"uploaded_to":["The uploaded to field is required."]}

Looking at the payload, that error should not be showing. uploaded_to=2 is set in the payload.

@Jcdiem commented on GitHub (Feb 1, 2022): The response returned was `{"uploaded_to":["The uploaded to field is required."]}` Looking at the payload, that error should not be showing. `uploaded_to=2` is set in the payload.
Author
Owner

@ssddanbrown commented on GitHub (Feb 1, 2022):

Very strange, any modifications or theme overrides active on your system?

@ssddanbrown commented on GitHub (Feb 1, 2022): Very strange, any modifications or theme overrides active on your system?
Author
Owner

@ssddanbrown commented on GitHub (Feb 1, 2022):

In addition:

  • Is this a fresh system?
  • If you perform a search via the search bar at the top, does changing the search term change the results and do you see the "Search Terms" box in the sidebar become populated?
@ssddanbrown commented on GitHub (Feb 1, 2022): In addition: - Is this a fresh system? - If you perform a search via the search bar at the top, does changing the search term change the results and do you see the "Search Terms" box in the sidebar become populated?
Author
Owner

@Jcdiem commented on GitHub (Feb 1, 2022):

  • Yes, this is a fresh system. I spun up the VM on an ESXI server just a few hours ago to install BookStack
  • Changing the term doesn't change search results, and the sidebar does not populate
@Jcdiem commented on GitHub (Feb 1, 2022): - Yes, this is a fresh system. I spun up the VM on an ESXI server just a few hours ago to install BookStack - Changing the term doesn't change search results, and the sidebar does not populate
Author
Owner

@ssddanbrown commented on GitHub (Feb 1, 2022):

@Jcdiem It sounds like query parameters are not being handled correctly. I've typically seen this in misconfigured nginx setups, commonly where try_files is missing a question mark. Reference.

@ssddanbrown commented on GitHub (Feb 1, 2022): @Jcdiem It sounds like query parameters are not being handled correctly. I've typically seen this in misconfigured nginx setups, commonly where `try_files` is missing a question mark. [Reference](https://github.com/BookStackApp/devops/blob/02f356cda1b32f4aea85ec9b0bf574be8abbe449/config/nginx/ubuntu-1604-install-config#L11).
Author
Owner

@Jcdiem commented on GitHub (Feb 1, 2022):

That was it! When copying over my nginx config I left that out.

Closing the issue as changing
try_files $uri $uri/ /index.php$query_string;
to
try_files $uri $uri/ /index.php?$query_string;
in my nginx site configuration worked.

@Jcdiem commented on GitHub (Feb 1, 2022): That was it! When copying over my nginx config I left that out. Closing the issue as changing `try_files $uri $uri/ /index.php$query_string;` to `try_files $uri $uri/ /index.php?$query_string;` in my nginx site configuration worked.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/BookStack#2620