Skip to content

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

Open
soyuka wants to merge 2 commits into
api-platform:mainfrom
soyuka:worktree-fix+issue-8354
Open

fix(symfony): allow null $data in PlaceholderAction#8359
soyuka wants to merge 2 commits into
api-platform:mainfrom
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 added 2 commits May 19, 2026 16:37
Allows defining JSON-LD namespace prefix entries (e.g. `dct:
http://purl.org/dc/terms/`) directly on ApiResource/HttpOperation,
which get merged into the generated `@context` output.

Closes api-platform#767
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
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