knuckleswtf / scribe

Generate API documentation for humans from your Laravel codebase.✍
https://scribe.knuckles.wtf/laravel/
MIT License
1.69k stars 303 forks source link

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

Open dlebech opened 1 week ago

dlebech commented 1 week ago

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

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: https://github.com/knuckleswtf/scribe/blob/3ab4ae7029b3db58b5509e3721b2dc146f04a17e/src/Extracting/InstantiatesExampleModels.php#L56

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

shalvah commented 6 days ago

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 👍