Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enforces topic and pubsubName for publishing events. #2091

Merged
merged 2 commits into from
Sep 24, 2020

Conversation

artursouza
Copy link
Member

Description

Enforces topic and pubsubName for publishing events.

Issue reference

We strive to have all PR being opened based on an issue, where the problem or feature have been discussed prior to implementation.

Please reference the issue this PR will close: #2061

Checklist

Please make sure you've completed the relevant tasks for this PR, out of the following list:

@artursouza
Copy link
Member Author

/ok-to-test-windows

@dapr-bot
Copy link
Collaborator

Found the available test cluster - dapr-aks-e2e-06 for linux. Please check the build status.

@codecov
Copy link

codecov bot commented Sep 24, 2020

Codecov Report

Merging #2091 into master will increase coverage by 0.65%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2091      +/-   ##
==========================================
+ Coverage   43.81%   44.46%   +0.65%     
==========================================
  Files          69       69              
  Lines        6028     6041      +13     
==========================================
+ Hits         2641     2686      +45     
+ Misses       3163     3123      -40     
- Partials      224      232       +8     
Impacted Files Coverage Δ
pkg/grpc/api.go 20.06% <100.00%> (+6.44%) ⬆️
pkg/http/api.go 47.24% <100.00%> (+3.15%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update da74c99...02e2738. Read the comment docs.

pkg/http/api.go Outdated
@@ -179,7 +179,7 @@ func (a *api) constructPubSubEndpoints() []Endpoint {
return []Endpoint{
{
Methods: []string{fasthttp.MethodPost, fasthttp.MethodPut},
Route: "publish/{pubsubname}/{topic:*}",
Route: "publish/{pubsubname}/{topic}",
Copy link
Contributor

@youngbupark youngbupark Sep 24, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I recall that we allowed slash-included topic name so that we use :*.

@yaron2 @mchmarny / Didn't we ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well. This fixed the bug. Users should provide encoded / in http. It is one of those %something type of encoding.

Copy link
Contributor

@youngbupark youngbupark Sep 24, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah technically, url needs to be uuencoded chars. but, as I recall, we allows to use publish/{pubsubname}/topic/A/B. then Dapr routes it to topic/A/B path of http server...
if we change the behavior, it will be the breaking change :)

but I would like to double-check with @yaron2 @mchmarny

Copy link
Member

@yaron2 yaron2 Sep 24, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are correct, this needs to be reverted back. It breaks the complex topic feature.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let me take another look at it. There is another way to fix it.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That check was only in the GRPC API. For HTTP, I tried to solve via the route setting.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct, our code was already validating the presence of component, we were just missing the check on nil topic which can result from trailing slash on publish POST for example. this LGTM

So :* is just for trailling slash? then this fix will be fine.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, * is not for trailing slash. The change needs to be reverted to include *.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Put it back and added more unit tests for the HTTP route to make sure this bug does not come back when someone messes with the HTTP route again.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 unittest

@dapr-bot
Copy link
Collaborator

End-to-end tests failed on linux. Please check the build logs

mchmarny
mchmarny previously approved these changes Sep 24, 2020
Copy link
Member

@mchmarny mchmarny left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

@yaron2
Copy link
Member

yaron2 commented Sep 24, 2020

/ok-to-test

@dapr-bot
Copy link
Collaborator

Found the available test cluster - dapr-aks-e2e-05 for linux. Please check the build status.

@dapr-bot
Copy link
Collaborator

Congrats! All end-to-end tests have passed on linux. Thanks for your contribution!

@artursouza artursouza merged commit 9a4788d into dapr:master Sep 24, 2020
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.

Publishing to component w/o without topic returns 200
5 participants