Skip to content

[make:webhook] Fix the crash under --no-interaction - #1817

Draft
wachterjohannes wants to merge 1 commit into
symfony:1.xfrom
wachterjohannes:fix/make-webhook-non-interactive
Draft

[make:webhook] Fix the crash under --no-interaction#1817
wachterjohannes wants to merge 1 commit into
symfony:1.xfrom
wachterjohannes:fix/make-webhook-non-interactive

Conversation

@wachterjohannes

Copy link
Copy Markdown
Member
Q A
Bug fix? yes
New feature? no
Deprecations? no
License MIT

make:webhook already declares its name argument, and already marks it non-interactive, so it looks scriptable. It is not:

$ php bin/console make:webhook remote_service --no-interaction
Typed property Symfony\Bundle\MakerBundle\Maker\MakeWebhook::$name must not be accessed
before initialization

Cause

interact() read the argument and copied it onto the maker, and generate() read it back from there. Command::run() skips interact() under --no-interaction, so the copy never happened. $io was stashed on the maker in the same way.

Fix

generate() reads the argument it was given. The name check that interact() applied moved next to that read, so a name with illegal characters is rejected on both paths rather than only when someone is watching. $io is passed to the one private method that asks anything, and both properties are gone.

symfony/webhook was installed from interact(), which is the one step that does not always run, and the generated request parser extends AbstractRequestParser from that package. The install moved to generate(), which always runs, rather than being called from both: a second composer require in the same process rebuilds the container underneath the running command, and the run then dies on a stale cache file. The one visible change interactively is that the install now happens after the questions instead of before.

Tests

Two non-interactive cases in MakeWebhookTest: one generating the parser and the consumer and checking the webhook.yaml routing entry, one asserting an invalid name is rejected before anything is written. The first fails on 1.x with the error above.

Why

Part of a series making the makers usable by coding agents, which cannot answer prompts. Same framing as #1814 and #1815.

The name argument was already declared, and already marked
non-interactive, but interact() copied it onto the maker and generate()
read it back from there. Command::run() skips interact() without a
terminal, so the copy never happened:

    $ php bin/console make:webhook remote_service --no-interaction
    Typed property MakeWebhook::$name must not be accessed before
    initialization

generate() now reads the argument it was given. The name check that
interact() applied moved next to it, so a name with illegal characters
is rejected on both paths instead of only when someone is watching.

symfony/webhook was installed from interact(), which is the one place
that does not always run, and the generated parser extends a class from
that package. The install moved to generate(), the step that always
runs, rather than being called from both: a second composer require in
the same process rebuilds the container underneath the command and the
run dies afterwards on a stale cache file.

$io was being stashed on the maker as well. It is passed to the one
private method that asks anything, and the property is gone along with
the one holding the name.
@wachterjohannes
wachterjohannes force-pushed the fix/make-webhook-non-interactive branch from 15359ec to f56af5c Compare August 31, 2026 17:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant