Skip to content

ArgumentsValidationException logged as critical #1193

Open
@nicolas-codemate

Description

@nicolas-codemate
Q A
Bug report? no
Feature request? yes
BC Break report? no
RFC? no
Version/Branch 1.5.0

Hi,

I use the ArgumentsValidationException in mutations frequently to ensure my model adheres to business logic using Symfony asserts.

It's very handy because validation errors are properly displayed without much effort.

The problem is these kinds of exception are logged as critical (see

public function onErrorFormatting(ErrorFormattingEvent $event): void
)

In my opinion, it should behave exactly like UserError (logged as Error).

What do you think ?

Proposals :

  • Make ArgumentsValidationException extends UserError
  • since ArgumentsValidationException implement ClientAware and marked as "ClientSafe"
// Overblog\GraphQLBundle\EventListener\ErrorLoggerListener

    public function onErrorFormatting(ErrorFormattingEvent $event): void
    {
        // ...

        if ($exception instanceof UserWarning) {
            if ($exception->getPrevious()) {
                $this->log($exception->getPrevious(), LogLevel::WARNING);
            }

            return;
        }

        if ($exception instanceof ClientSafe) {
            if ($exception->getPrevious() && $exception->isClientSafe()) {
                $this->log($exception->getPrevious());
            }

            return;
        }

        $this->log($exception, LogLevel::CRITICAL);
  • something else ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions