invoiceninja / dockerfiles

Docker files for Invoice Ninja
https://hub.docker.com/r/invoiceninja/invoiceninja
GNU General Public License v2.0
420 stars 269 forks source link

Long public notes on Clean design breaks PDF generator #422

Closed souldessin closed 2 days ago

souldessin commented 2 years ago

Hey guys, I wanted to let you know that I'm getting a 500 error when I click to generate the PDFs. Below are the docker logs at the time that it happens. As you can see I get a page found on the unique url, but then It just throws me a 500.

app_1     | 172.18.0.4 -  03/Jan/2022:17:58:05 +0000 "GET /index.php" 302
server_1  | 172.18.0.1 - - [03/Jan/2022:17:58:05 +0000] "GET /client/invoice/L1egV6xjTNoBvP3k2tljFWDWmONiuILg/download?t=1641232685350&per_page=999999 HTTP/1.1" 302 630 "-" "Dart/2.15 (dart:io)" "192.168.1.1"
server_1  | 172.18.0.1 - - [03/Jan/2022:17:58:10 +0000] "GET /client/invoice/L1egV6xjTNoBvP3k2tljFWDWmONiuILg/download_pdf HTTP/1.1" 500 44 "-" "Dart/2.15 (dart:io)" "192.168.1.1"
app_1     | 172.18.0.4 -  03/Jan/2022:17:58:05 +0000 "GET /index.php" 500

I do have TRUSTED_PROXIES=* and the PDF_GENERATOR=snappdf in my env file. It did work until I updated to v5.39.

Appreciate the work you do.

turbo124 commented 2 years ago

Can you check the logs for errors in storage/logsl/laravel-error.log

souldessin commented 2 years ago

I don't have a laravel-error.log, just a laravel.log, in my storage/logs/ folder.

I'm sorry for the edits. I forgot that I ended up not using my NFS storage and left things nearly identical to the original yml file (only needed changes). Still, I don't have a laravel-error.log

souldessin commented 2 years ago

Aaaand, I just got one of them to display by marking it sent. I had it as a draft and wanted to make sure it was displaying properly before sending it. Fast forward to just this moment, I figured that I would check an old invoice and see if I could get a PDF. I did, so I tried marking it sent.

I had made two invoices, and one had an attachment and was the last invoice made and it still gives a 500 error, though.

turbo124 commented 2 years ago

@souldessin NFS could be the issue particularly if it doesn't like having the UID set (or if you haven't atttempted to chown the directories) to 1500:1500

souldessin commented 2 years ago

I double checked and, while I still don't have that error.log, all of the files & directories in the docker/app folder are 1500:1500. The NFS was in my head from my original config a few months back, but isn't used. It is a most peculiar issue.

I've come to the conclusion that the issue lies somewhere in one invoice. The problem is that it was created not only by converting a task into an invoice, but it had an attachment when I sent it. I tried removing the attachment (a PDF), and it still won't display a PDF of the invoice.

Also, just in case, I'm running 5.39 with a latest pull from docker hub.

turbo124 commented 2 years ago

It sounds like a permissions issue, I'm not sure there can be any other explanation. There will be logs in storage/logs/laravel.log with further information.

souldessin commented 2 years ago

That was the odd thing. All that I saw in the laravel.log was notices of updates and artisan runs/error traces (from updates and upgrades).

Where is the option to put it into devel mode? I'm going to try seeing if I can get the full trace to help.

souldessin commented 2 years ago

@turbo124 I just found the issue. The public notes were too long and causing an issue with the PDF generator. Now, I am using the "Clean" invoice design without any alterations beside adding a logo. Below are the two notes.

The long one that broke things:

This was for the time spent installing and configuring the new stage lighting controller. For more information, please see the attached PDF for the complexity of the data that needed to be manually recorded and reentered into the new software due to the use of a system that hid values and didnt have a proper backup method.

The short one that worked:

This was for the time spent installing and configuring the new stage lighting controller. See the attached file for the complexity of the transferred data.

In the end I didn't see the issue because the stack trace was being logged to laravel.log, hence no laravel-error.log. It was also so long that I just missed it somehow (wall of text and all that). I suspect because the bottom is just laravel framework items I assumed it was a continuation from when I had issue a few months ago.

Below is the beginning of the stacktrace:

[2022-01-07 15:39:57] production.ERROR: Array to string conversion {"exception":"[object] (ErrorException(code: 0): Array to string conversion at /var/www/app/app/Services/PdfMaker/Design.php:627)
[stacktrace]
#0 [internal function]: Illuminate\\Foundation\\Bootstrap\\HandleExceptions->handleError()
#1 /var/www/app/app/Services/PdfMaker/Design.php(627): strtr()
#2 /var/www/app/app/Services/PdfMaker/Design.php(154): App\\Services\\PdfMaker\\Design->tableTotals()
#3 /var/www/app/app/Jobs/Entity/CreateEntityPdf.php(167): App\\Services\\PdfMaker\\Design->elements()
#4 /var/www/app/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(36): App\\Jobs\\Entity\\CreateEntityPdf->handle()
#5 /var/www/app/vendor/laravel/framework/src/Illuminate/Container/Util.php(40): Illuminate\\Container\\BoundMethod::Illuminate\\Container\\{closure}()
turbo124 commented 2 years ago

@souldessin

It is actually just one word that is causing the issue values is a protected word in this section. We'll need to figure a way to handle this.