Photo of DeepakNess DeepakNess

SharePDF payment bug: billing checkout 500

Spent several hours debugging a sneaky bug on SharePDF. Whenever someone clicked Upgrade to Pro/Max on the subscription page, then it showed 500 errors.

The failing request was:

  • POST /billing/checkout

What made this confusing was that app logs were almost empty and only showing scheduler info, so at first it looked like checkout/API issue.

The actual issue was file permissions.

  • PHP-FPM was running web requests as nobody.
  • storage/logs/laravel.log was owned by root:root and not writable by nobody.
  • Checkout flow writes logs during request, and log write failure was causing the 500.

Quick checks I used:

cd /app
ps -eo user,pid,comm | grep php-fpm
ls -lah /app/storage/logs/laravel.log
su -s /bin/sh nobody -c 'echo test >> /app/storage/logs/laravel.log'

If the last command says Permission denied, this is very likely the same problem.

Fix I used:

touch /app/storage/logs/laravel.log
chmod 666 /app/storage/logs/laravel.log

Then I made it persistent by adding the same in startup script, so every deploy keeps the log writable before traffic hits.

Also hardened checkout so even if logging fails, checkout request itself does not fail just because of logging.

If this happens again:

  1. Check log file write permission first.
  2. Confirm startup script ran in latest deploy.
  3. Retry checkout once after permission fix.
  4. Then tail logs for the real error (if any):
tail -f /app/storage/logs/laravel.log

I am just taking these notes for myself, for the future.

Webmentions

What’s this?