dapr icon indicating copy to clipboard operation
dapr copied to clipboard

GET statestore API fails for keys with slashes despite successful save

Open guerrerocarlos opened this issue 6 months ago • 1 comments

/area runtime

What version of Dapr?

1.15.5

Expected Behavior

GET operations to the Dapr State API should support keys that contain any valid character, including slashes (/). This flexibility is critical for many use cases where structured or hierarchical keys are used (e.g., user/123/settings).

Saving such keys (with slashes) works fine using the POST/PUT methods, indicating that the underlying state store does not impose this limitation. Therefore, the GET operation should not impose restrictions that are inconsistent with the save operation or the underlying store capabilities.

Actual Behavior

When attempting to retrieve a key with a slash (/) in its value via the GET endpoint:

GET http://localhost:<daprPort>/v1.0/state/<storename>/<key-with-slash>

The following error is returned:

{
  "error": "Not Found",
  "error_msg": "{\"errorCode\":\"ERR_DIRECT_INVOKE\",\"message\":\"failed getting app id either from the URL path or the header dapr-app-id\"}",
  "status": 404
}

This error is misleading—it refers to a failure to get the app id, which is unrelated to the actual issue (a malformed URL due to the unescaped slash).

Steps to Reproduce the Problem

  1. Save a state value with a key that includes a slash:
curl -X POST http://localhost:<daprPort>/v1.0/state/<storename> \
-H "Content-Type: application/json" \
-d '[{"key": "user/123/settings", "value": "dark_mode"}]'
  1. Try to retrieve the state:
curl http://localhost:<daprPort>/v1.0/state/<storename>/user/123/settings
  1. Observe the 404 response and unrelated error message.

Technical Proposal

Suggested Fix: Allow the GET endpoint to accept keys that contain special characters, especially slashes, by:

GET /v1.0/state/<storename>/user%2F123%2Fsettings

Alternatively, allow the key to be passed as a query parameter to bypass path-related encoding issues:

GET /v1.0/state/<storename>?key=user/123/settings

This approach ensures full support for hierarchical and structured keys without breaking existing storage patterns or introducing unnecessary constraints.

Release Note

RELEASE NOTE: FIX Allow GET state API to support keys with special characters (e.g., slashes) by enabling proper decoding or supporting query parameter access.

guerrerocarlos avatar May 29 '25 15:05 guerrerocarlos

Can I work on this issue

cr3ativ3cod3r avatar Jun 03 '25 12:06 cr3ativ3cod3r

This issue has been automatically marked as stale because it has not had activity in the last 90 days. It will be closed in the next 7 days unless it is tagged (pinned, good first issue, help wanted or triaged/resolved) or other activity occurs. Thank you for your contributions.

dapr-bot avatar Oct 12 '25 20:10 dapr-bot

This issue has been automatically closed because it has not had activity in the last 97 days. If this issue is still valid, please ping a maintainer and ask them to label it as pinned, good first issue, help wanted or triaged/resolved. Thank you for your contributions.

dapr-bot avatar Oct 19 '25 20:10 dapr-bot