Skip to content

Fix TypeError in deleteState(): allow null etag - #154

Open
hexmode wants to merge 1 commit into
dapr:mainfrom
hexmode:fix-delete-state-etag
Open

hexmode wants to merge 1 commit into
dapr:mainfrom
hexmode:fix-delete-state-etag

Conversation

@hexmode

@hexmode hexmode commented Sep 21, 2026

Copy link
Copy Markdown

Description

deleteStateAsync() calls tryDeleteStateAsync($storeName, $key, null, ...) (delete without an etag), but tryDeleteStateAsync() declares string $etag (non-nullable), so every deleteState() call fatals:

TypeError: tryDeleteStateAsync(): Argument #3 ($etag) must be of type string, null given

The method body already handles an empty etag (it only sends the If-Match header when !empty($etag)), so the fix is to widen $etag to string|null on both tryDeleteState and tryDeleteStateAsync (abstract declaration + HTTP implementation). Surfaced while building a PHP state-management quickstart for dapr/quickstarts.

Issue reference

Fixes #153

Checklist

  • Tests pass — full suite green (109 tests); 2 new regression tests in tests/DeleteStateTest.php (delete without etag sends no If-Match; delete with etag sends If-Match)
  • Created/updated tests
  • Extended the documentation — n/a (bug fix, no API/behavior change beyond not crashing)

deleteStateAsync() passes null as the etag to tryDeleteStateAsync(),
whose $etag parameter is typed as non-nullable string, so any call to
deleteState() fatals with:

  TypeError: tryDeleteStateAsync(): Argument dapr#3 ($etag) must be of type
  string, null given

The implementation already handles an empty etag (no If-Match header is
sent), so widen the parameter to string|null on both tryDeleteState and
tryDeleteStateAsync (abstract + HTTP implementation) and add regression
tests for deleting with and without an etag.

Signed-off-by: Mark A. Hershberger <mah@nichework.com>
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.

deleteState() fatals with TypeError (null etag passed to non-nullable string param)

1 participant