0

I am working in a Laravel Valet php7.4 environment, on a Laravel 7.4 app. With this, I have created a form request that updates a user's bio, with the following validation: 'bio' => ['nullable', 'max:255']

Whenever I put a huge amount of characters in, my local (Nginx) server seems to collapse and Laravel isn't pooping out the error by validation. I was getting Valet 502 Bad Gateway errors, that I fixed by adding this to the valet config:

fastcgi_buffers 16 16k;
fastcgi_buffer_size 32k;

Now the 502 errors are gone, but it is still not Laravel that is catching the request error. Any ideas why?

Edit: some more information on the request part

Form:

<form
    class="form"
    method="POST"
    action="{{ route('settings.profile.update') }}"
>
    {{ csrf_field() }}
    {{ method_field('PATCH') }}

    <div class="form-group">
        <x-input-textarea
            label="Bio"
            name="bio"
            :value="$user->profile->bio"
            ref="bio"
        />
    </div>
    
    <x-button
        class="button--primary"
        label="Opslaan"
    />
</form>

The textarea Blade component

<div class="form-field">
    @isset( $label )
        <label class="label" for="{{ $name }}">{{ $label }}</label>
    @endif

    <textarea
        {{ $attributes->merge(['class' => "input input--textarea"]) }}
        name="{{ $name }}"
        id="{{ $name }}"
        placeholder="{{ $placeholder ?? ($label ?? null) }}"
        {{ ($required ?? false) ? 'required' : '' }}
        {{ isset($autocomplete) ? 'autocomplete=' . $autocomplete : '' }}
    >{{ old($name, $value ?? '') }}</textarea>

    @if( $errors->has($name) )
        <x-input-message
            :message="$errors->first($name)"
        />
    @elseif( $hint )
        <p class="mt-xxsmall text-meta">
            {{ $hint }}
        </p>
    @endif
</div>

The Controller

public function update(ProfileRequest $request)
{
    ...// authorization

    // job
    ProfileUpdateJob::dispatchNow($request, $user);

    ...// returning stuff
}

The Profile Update Job

public function handle()
{
    $input = $this->request->validated();
    $this->user->profile()->update($input);
}
intergalactisch
  • 109
  • 2
  • 7

1 Answers1

0

I was also having this issue, even after tweaking my nginx configuration. In the end, the issue was addressed when I changed my LOG_CHANNEL from errorlog to something else, such as daily (note: stack may have errorlog in it, so watch out for that). Debugging this further, it seemed the stacktrace logged when errorlog is used, is too large for php to return back to nginx, hence the generic nginx 500 error. This may be able to be resolved by further tweaking the nginx settings, but I couldn't resolve it that way.

alexkb
  • 3,216
  • 2
  • 30
  • 30