Closed heunghingwan closed 9 months ago
Add empty checking after some reading in dapr/dapr#6461
Take for example the route v1.0/state/{storeName}/{key}. Before, passing an empty {storeName}, such as v1.0/state//somekey would have still invoked the handler, which would have received an empty "storeName" (and likely returned 400 - bad request). Because the router now normalizes paths and removes double slashes (see https://github.com/dapr/dapr/issues/6324), the path is converted to v1.0/state/somekey, so it now returns a 404 because it can't match any route.
Can we still change if (id === "") throw new Error("ActorId cannot be empty");
?
Can we still change
if (id === "") throw new Error("ActorId cannot be empty");
?
Yes, it will be more versatile when importing in a javascript-only application
Can we still change
if (id === "") throw new Error("ActorId cannot be empty");
?Yes, it will be more versatile when importing in a javascript-only application
Perfect! But please use the multi line if instead of single one
if (!id) {
...
}
@heunghingwan were you able to test your scenario from the issue with this PR?
Since we are decoding back in getId
, it should still not work since the ID will contain special characters again.
@heunghingwan were you able to test your scenario from the issue with this PR?
Since we are decoding back in
getId
, it should still not work since the ID will contain special characters again.
You are right, maybe add a getURISafeId function, or encoded in ActorClientHTTP.ts, to provide unencoded id for grpc use?
All modified and coverable lines are covered by tests :white_check_mark:
Comparison is base (
b063e10
) 100.00% compared to head (59379c8
) 100.00%. Report is 3 commits behind head on main.
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
@XavierGeerinck one issue I see with this change is, we are introducing a parity between HTTP and gRPC actor clients. HTTP will use a sanitized actor ID, and gRPC won't. This means there will be interop issues b/w the two protocols.
I would propose to modify gRPC's behavior too and keep it consistent. Thoughts?
@XavierGeerinck one issue I see with this change is, we are introducing a parity between HTTP and gRPC actor clients. HTTP will use a sanitized actor ID, and gRPC won't. This means there will be interop issues b/w the two protocols.
I would propose to modify gRPC's behavior too and keep it consistent. Thoughts?
It should not behave differently, actor ID in gRPC is transmitted as-is, actor ID in HTTP should be decoded in core
@heunghingwan I see, it should be fine in that case, thanks for your contribution!
Description
Throw when actor id contain '/'
Issue reference
issue this PR will close: #537
Checklist
Please make sure you've completed the relevant tasks for this PR, out of the following list: