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

Exceptions during Model factory creation for API endpoints are never printed -- no matter verbose setting #891

Open
1 task done
dlebech opened this issue Sep 16, 2024 · 1 comment
Labels
bug Something isn't working validated

Comments

@dlebech
Copy link

dlebech commented Sep 16, 2024

Scribe version

4.37.0

PHP version

8.2

Framework

Laravel

Framework version

11.12.0

Scribe config

title => "API Documentation"
auth.name => "Authorization"
strategies.responses => added [
    'Knuckles\\Scribe\\Extracting\\Strategies\\Responses\\ResponseCalls',
    [
        'only' => [
            'GET *',
        ],
    ],
]: removed [
    'Knuckles\\Scribe\\Extracting\\Strategies\\Responses\\ResponseCalls',
    [
        'only' => [
            'GET *',
        ],
        'config' => [
            'app.debug' => false,
        ],
    ],
]

What happened?

Reproduce

  • I run php artisan scribe:generate -vvv (or php artisan scribe:generate --verbose)
  • I see some warnings for my models like "Couldn't get example model App\Model[modelname] via factoryCreate
  • I expected to see exception output (and stack trace) for each of these warnings, so I can debug the issue, but I only get the warning.

Explanation/analysis

The reason there is no exception output is that $completelySilent parameter for the function dumpExceptionIfVerbose is always set to true in the model factory exception handler:

e::dumpExceptionIfVerbose($e, true);

Possible fix

I would expect that the parameter $completelySilent should either be absent or false in the code mentioned above. When I go to the vendor/ source and change that line to false, I get the stacktrace and exception output as expected.

I can submit a PR for this, if you agree with my analysis.

Docs

@dlebech dlebech added bug Something isn't working triage labels Sep 16, 2024
@dlebech dlebech changed the title Exceptions during Model instantiation are never printed -- no matter verbose setting Exceptions during Model creation for API endpoints are never printed -- no matter verbose setting Sep 16, 2024
@dlebech dlebech changed the title Exceptions during Model creation for API endpoints are never printed -- no matter verbose setting Exceptions during Model factory creation for API endpoints are never printed -- no matter verbose setting Sep 16, 2024
@shalvah
Copy link
Contributor

shalvah commented Sep 17, 2024

Yeah, I think the reason for that was to limit noise, since model instantiation was not very customizable in the past. But you're correct, this shouldn't swallow exceptions. PR welcome 👍

@shalvah shalvah added validated and removed triage labels Nov 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working validated
Projects
None yet
Development

No branches or pull requests

2 participants