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

🐛500 Error When Creating New Event Due to HTMLPurifier Cache Directory Not Writable #319

Open
Wladefant opened this issue Dec 17, 2024 · 5 comments
Labels
bug Something isn't working Deployment Issue

Comments

@Wladefant
Copy link

Description

When creating a new event, the backend throws a 500 Internal Server Error. The issue is caused because the HTMLPurifier library cannot write to its cache directory (DefinitionCache/Serializer).


Error Logs

[2024-12-17 12:36:51] local.DEBUG: Stripe secret key is not set in the configuration file. Payment processing will not work.   
[2024-12-17 12:36:51] local.ERROR: Directory /app/vendor/ezyang/htmlpurifier/library/HTMLPurifier/DefinitionCache/Serializer not writable.  
{"userId":1,"exception":"[object] (ErrorException(code: 0): Directory /app/vendor/ezyang/htmlpurifier/library/HTMLPurifier/DefinitionCache/Serializer not writable.  
at /app/vendor/ezyang/htmlpurifier/library/HTMLPurifier/DefinitionCache/Serializer.php:295)

Stack Trace:

#0 /app/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php(256): Illuminate\Foundation\Bootstrap\HandleExceptions->handleError(512, 'Directory /app/...', '/app/vendor/ezy...', 295)
#1 [internal function]: Illuminate\Foundation\Bootstrap\HandleExceptions->{closure}(512, 'Directory /app/...', '/app/vendor/ezy...', 295)
#2 /app/vendor/ezyang/htmlpurifier/library/HTMLPurifier/DefinitionCache/Serializer.php(295): trigger_error('Directory /app/...', 512)
...
#11 /app/app/Services/Domain/Event/CreateEventService.php(91): HTMLPurifier->purify('<p>asdf</p>')
#14 /app/app/Http/Actions/Events/CreateEventAction.php(39): HiEvents\Services\Handlers\Event\CreateEventHandler->handle(Object(HiEvents\Services\Handlers\Event\DTO\CreateEventDTO))
...
#59 /app/public/index.php(51): Illuminate\Foundation\Http\Kernel->handle(Object(Illuminate\Http\Request))
#60 {main}

Steps to Reproduce

  1. Go to the /events endpoint and attempt to create a new event.
  2. The server returns a 500 Internal Server Error.
  3. Logs indicate the DefinitionCache/Serializer directory is not writable.

Expected Behavior

The event should be created successfully without errors.


Actual Behavior

The server throws a 500 error due to a write permission issue.


Root Cause

  1. HTMLPurifier Cache Directory Issue:
    The DefinitionCache/Serializer directory does not have the correct write permissions, causing HTMLPurifier to fail when attempting to write cache data.

  2. Stripe Configuration:
    The Stripe secret key is missing in the .env file.


Environment

  • running in docker the Local development version without stripe or keys
@Wladefant Wladefant added the bug Something isn't working label Dec 17, 2024
@daveearley
Copy link
Contributor

Hi @Wladefant,

How are you starting the container? The Dockerfile handles this already.

@Wladefant
Copy link
Author

I am starting the docker/development start.sh Script and then this error comes

@daveearley
Copy link
Contributor

That's odd, the start-dev.sh should be making that directory writable. When you run start-dev.sh, is the script executing successfully?

As a workaround you can SSH into the container and run:

chmod -R 775 /app/vendor/ezyang/htmlpurifier/library/HTMLPurifier/DefinitionCache/Serializer

@daveearley
Copy link
Contributor

Any update on this? Did you get it working?

@Wladefant
Copy link
Author

Wladefant commented Jan 14, 2025

No, that all does not work, that seems to be a permission settings issue, I have tried all kinds of permissions, I have tried on windows, wsl, straight linux.

Does it work for you?

It seems to be the same error over and over again:
. HTMLPurifier “not writable” Error
HTMLPurifier is trying to create/write cache files in:

bash
Copy code
/app/vendor/ezyang/htmlpurifier/library/HTMLPurifier/DefinitionCache/Serializer

Here is my chat with chatgpt:
https://chatgpt.com/share/678638a0-de18-8004-b228-edfaac457d95

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Deployment Issue
Projects
None yet
Development

No branches or pull requests

2 participants