Skip to content

fix(symfony): allow null $data in PlaceholderAction#8359

Merged
soyuka merged 1 commit into
api-platform:4.3from
soyuka:worktree-fix+issue-8354
Jun 30, 2026
Merged

fix(symfony): allow null $data in PlaceholderAction#8359
soyuka merged 1 commit into
api-platform:4.3from
soyuka:worktree-fix+issue-8354

Conversation

@soyuka

@soyuka soyuka commented Jun 26, 2026

Copy link
Copy Markdown
Member

Bug

In event-listener mode (use_symfony_listeners: true), a POST operation with input: false and a custom processor returns a 500:

Could not resolve argument $data of api_platform.action.placeholder::__invoke()

Root cause

The data request attribute is set by either ReadProvider or DeserializeProvider:

  • ReadProvider skips when canRead() is false — auto-false for POST (no URI variables, unsafe method).
  • DeserializeProvider skips when input: falsecanDeserialize() is false.

With both skipped the attribute is never set, so Symfony's argument resolver cannot fill the untyped, no-default $data parameter of PlaceholderAction. The non-listener MainController path is unaffected because it runs the state machine with $data = null.

Fix

Default PlaceholderAction::__invoke($data = null) so the argument resolver supplies null when the attribute is absent — matching the non-listener flow where the processor receives null.

Tests

InputOutputDtoTest::testCreateNoInputResource was previously skipped in listener mode with the marker "PlaceholderAction cannot resolve $data when input:false in event-listener mode.". The skip is removed and the test now passes in both modes (USE_SYMFONY_LISTENERS=1 and off).

Closes #8354

@soyuka soyuka changed the base branch from main to 4.3 June 29, 2026 08:14
@soyuka soyuka force-pushed the worktree-fix+issue-8354 branch 2 times, most recently from 0dba2f4 to 9d67fa1 Compare June 29, 2026 15:08
In event-listener mode a POST with input:false (and no read) never
sets the "data" request attribute, so Symfony's argument resolver
fails with "Could not resolve argument $data". Default the argument
to null, mirroring the non-listener state-machine flow.

Closes api-platform#8354
@soyuka soyuka force-pushed the worktree-fix+issue-8354 branch from 9d67fa1 to 70276a8 Compare June 29, 2026 15:09
@soyuka soyuka merged commit fe84af2 into api-platform:4.3 Jun 30, 2026
111 of 112 checks passed
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.

use_symfony_listeners: true with read + input disabled leads to Could not resolve argument $data

1 participant