Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Could not create paste: Error saving paste. Sorry. #1122

Closed
zamunda68 opened this issue Jul 25, 2023 · 13 comments
Closed

Could not create paste: Error saving paste. Sorry. #1122

zamunda68 opened this issue Jul 25, 2023 · 13 comments

Comments

@zamunda68
Copy link

Steps to reproduce

  1. Open the PrivateBin web UI
  2. Click on the blue "Send" button

What happens

Could not create paste: Error saving paste. Sorry.

What should happen

There should be a link generated to the paste

Additional information

Basic information

Server OS: Rocky Linux 9.2

Webserver: NGINX 1.20.1

Browser: Chrome 114

PrivateBin version: 1.5.2

I can reproduce this issue on https://privatebin.net: Yes / No
No

@ppfeufer
Copy link

If this is by any chance a fresh Docker installation, see here (scroll down to "Fix Permissions") » https://ppfeufer.de/privatebin-your-self-hosted-pastebin-instance/

@zamunda68
Copy link
Author

It is not a Docker container installation, it is running inside a virtual machine, on the guest OS of the virtual machine itself.

@zamunda68
Copy link
Author

Does the application have any logs I can check? I am having a hard time debugging even with strace.

@ppfeufer
Copy link

ppfeufer commented Jul 25, 2023

Still, check the file permissions and the Nginx logs.

@fitzg2
Copy link

fitzg2 commented Jul 25, 2023

Happens intermittently to me too

Fatal error: Uncaught Exception: A JSON error occurred: Syntax error (4) in /var/www/html/pbin/lib/Json.php:76 Stack trace: #0 /var/www/html/pbin/lib/Json.php(52): PrivateBin\Json::_detectError() #1 /var/www/html/pbin/lib/Data/Filesystem.php(350): PrivateBin\Json::decode() #2 /var/www/html/pbin/lib/Data/Filesystem.php(113): PrivateBin\Data\Filesystem->_get() #3 /var/www/html/pbin/lib/Data/Filesystem.php(373): PrivateBin\Data\Filesystem->read() #4 /var/www/html/pbin/lib/Data/AbstractData.php(158): PrivateBin\Data\Filesystem->_getExpiredPastes() #5 /var/www/html/pbin/lib/Model.php(72): PrivateBin\Data\AbstractData->purge() #6 /var/www/html/pbin/lib/Controller.php(253): PrivateBin\Model->purge() #7 /var/www/html/pbin/lib/Controller.php(125): PrivateBin\Controller->_create() #8 /var/www/html/pbin/index.php(18): PrivateBin\Controller->__construct() #9 {main} thrown in /var/www/html/pbin/lib/Json.php on line 76

JSON in the request is

{"adata":[["xFjvTmlHGNJzqOBNap2RsA==","k0+EdB7tZ60=",100000,256,128,"aes","gcm","zlib"],"plaintext",0,0],"meta":{"expire":"1week"},"v":2,"ct":"8Ti/EWhW5aX5PzadXqUDAEFhpWLvFJsmhJBr2O2tCVV8tcKshUaX9dU="}

which looks valid?

Could it be php-json not being installed? That doesn't explain why sometimes it goes through and sometimes it returns that.

@zamunda68
Copy link
Author

@fitzg2 what logs are you checking?

@fitzg2
Copy link

fitzg2 commented Jul 25, 2023

@zamunda68 Nginx error logs clearly

@zamunda68
Copy link
Author

Lads, I found it - it was the SELinux. As soon as I set it to "permissive", the issue was resolved.

The command I used to set it to permissive:

setenforce 0

I will adjust its configuration.

Thank you for your help!

@rugk
Copy link
Member

rugk commented Jul 31, 2023

Just FYI: SeLinux is a security feature. By disabling it you are disabling a security feature of your OS.

This guide in our wiki may help and have some setup tips: https://github.com/PrivateBin/PrivateBin/wiki/Installation-on-Red-Hat-with-SELinux

@fitzg2
Copy link

fitzg2 commented Aug 18, 2023

This happens to me without SELinux. Same error still going on

2023/08/18 13:28:18 [error] 153573#153573: *195337 FastCGI sent in stderr: "PHP message: PHP Fatal error: Uncaught Exception: A JSON error occurred: Syntax error (4) in /var/www/html/pbin/lib/Json.php:76

Stack trace:
#0 /var/www/html/pbin/lib/Json.php(52): PrivateBin\Json::_detectError()
#1 /var/www/html/pbin/lib/Data/Filesystem.php(350): PrivateBin\Json::decode()
#2 /var/www/html/pbin/lib/Data/Filesystem.php(113): PrivateBin\Data\Filesystem->_get()
#3 /var/www/html/pbin/lib/Data/Filesystem.php(373): PrivateBin\Data\Filesystem->read()
#4 /var/www/html/pbin/lib/Data/AbstractData.php(158): PrivateBin\Data\Filesystem->_getExpiredPastes()
#5 /var/www/html/pbin/lib/Model.php(72): PrivateBin\Data\AbstractData->purge()
#6 /var/www/html/pbin/lib/Controller.php(253): PrivateBin\Model->purge()
#7 /var/www/html/pbin/lib/Controller.php(125): PrivateBin\Controller->_create()
#8 /var/www/html/pbin/index.php(18): PrivateBin\Controller->__construct()
#9 {main}
thrown in /var/www/html/pbin/lib/Json.php on line 76" while reading response header from upstream, client: w.x.y.z, server: > pastebin.x.dev, request: "POST / HTTP/1.1", upstream: "fastcgi://unix:/run/php/php7.4-fpm.sock:", host: "pastebin.x.dev"

@elrido
Copy link
Contributor

elrido commented Aug 20, 2023

@fitzg2 The JSON encoding error means that the message sent by the client to the server got mangled before it could reach the PHP logic. We try and document all the factors that commonly contribute to this in:
https://github.com/PrivateBin/PrivateBin/wiki/Configuration#sizelimit

Beyond those settings in the web- and php service, it can also occur if you use some kind of caching or loadbalancing service in front of your PrivateBin instance. You will have to carefully review your setup of each component in the stack to eliminate each possibility.

Likely duplicate of #263, #853, #858

@rugk rugk closed this as not planned Won't fix, can't repro, duplicate, stale Aug 21, 2023
@fitzg2
Copy link

fitzg2 commented Aug 21, 2023

It has nothing to do with size as the request is very small.

{"adata":[["RNP6g82Supr8eyquLzA4Qg==","lhV+sJMZrHk=",100000,256,128,"aes","gcm","zlib"],"plaintext",0,0],"meta":{"expire":"1week"},"v":2,"ct":"mlIdSUqLJyBX1UVb1PrPemnIYxp5T3yxx7lsJVMXVkMvaQ=="}

@elrido
Copy link
Contributor

elrido commented Aug 23, 2023

@fitzg2 If you've already caught an example JSON, you can use it to debug what in your stack is mangling it. You can use curl or a similar tool to repeatedly send the message to your instance and check on each layer of your stack what might cause the message to get modified:

curl -X POST --header 'X-Requested-With: JSONHttpRequest' --data '<your JSON here>' https://<your instance URL here>/

You can also verify what PHP actually receives by adding a var_dump($data); statement in the Controller.php's _create() method. This output should be returned from curl, before the exception.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants