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

Fix not removing tunnel route #1030

Merged
merged 6 commits into from
Aug 11, 2022

Conversation

vavsab
Copy link
Contributor

@vavsab vavsab commented Aug 9, 2022

Description

Fixes #1029

Has your change been tested?

All unit tests are green.

Screenshots (if appropriate):

Types of changes

What sort of change does your code introduce/modify?

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.
  • This change is using publicly documented (api.cloudflare.com or developers.cloudflare.com) and stable APIs.

@github-actions
Copy link
Contributor

github-actions bot commented Aug 9, 2022

changelog detected ✅

@codecov-commenter
Copy link

codecov-commenter commented Aug 9, 2022

Codecov Report

Merging #1030 (d1e5707) into master (6c5ea4a) will increase coverage by 0.12%.
The diff coverage is 58.13%.

@@            Coverage Diff             @@
##           master    #1030      +/-   ##
==========================================
+ Coverage   49.06%   49.18%   +0.12%     
==========================================
  Files         108      112       +4     
  Lines       10428    10549     +121     
==========================================
+ Hits         5116     5189      +73     
- Misses       4200     4232      +32     
- Partials     1112     1128      +16     
Impacted Files Coverage Δ
access_application.go 76.52% <ø> (ø)
access_bookmark.go 72.44% <ø> (ø)
workers_account_settings.go 35.71% <35.71%> (ø)
workers_tail.go 52.00% <52.00%> (ø)
workers_subdomain.go 57.14% <57.14%> (ø)
r2_bucket.go 100.00% <100.00%> (ø)
tunnel_routes.go 37.36% <100.00%> (ø)
filter.go 42.96% <0.00%> (+0.51%) ⬆️
firewall_rules.go 53.98% <0.00%> (+1.39%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

tunnel_routes.go Outdated Show resolved Hide resolved
@jacobbednarz
Copy link
Member

there is an alternative here that allows us to wrap this entire line in buildURI however, i'm not convinced this style of URI is something we want to cater for in the 99% of use cases.

diff --git utils.go utils.go
index 38d4315..39397bc 100644
--- utils.go
+++ utils.go
@@ -12,7 +12,7 @@ import (
 // buildURI assembles the base path and queries.
 func buildURI(path string, options interface{}) string {
        v, _ := query.Values(options)
-       return (&url.URL{Path: path, RawQuery: v.Encode()}).String()
+       return path + (&url.URL{RawQuery: v.Encode()}).String()
 }

 // loadFixture takes a series of path components and returns the JSON fixture at
diff --git utils_test.go utils_test.go
index 5973d8c..30f7a02 100644
--- utils_test.go
+++ utils_test.go
@@ -27,11 +27,14 @@ func Test_buildURI(t *testing.T) {
                "single level path with params":          {path: "/bar", params: testExample{C: "d"}, want: "/bar?c=d"},
                "single level path with multiple params": {path: "/foo", params: testExample{A: "b", C: "d"}, want: "/foo?a=b&c=d"},
                "single level path with nested fields":   {path: "/foo", params: testExample{A: "b", C: "d", PaginationOptions: PaginationOptions{PerPage: 10}}, want: "/foo?a=b&c=d&per_page=10"},
+               "escaped URL path":                       {path: "/foo/10.0.0.0%2F1", params: testExample{A: "b", C: "d"}, want: "/foo/10.0.0.0%2F1?a=b&c=d"},
+               "unescaped URL path":                     {path: "/foo/10.0.0.0/1", params: testExample{A: "b", C: "d"}, want: "/foo/10.0.0.0/1?a=b&c=d"},
        }

        for name, tc := range tests {
                t.Run(name, func(t *testing.T) {
                        got := buildURI(tc.path, tc.params)
+
                        assert.Equal(t, tc.want, got)
                })
        }

utils.go Outdated
@@ -12,7 +12,7 @@ import (
// buildURI assembles the base path and queries.
func buildURI(path string, options interface{}) string {
v, _ := query.Values(options)
return (&url.URL{Path: path, RawQuery: v.Encode()}).String()
return path + (&url.URL{RawQuery: v.Encode()}).String()
Copy link
Member

Choose a reason for hiding this comment

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

sorry, my comment must not have been clear. i'm still not sure if we want to do this; it was more of a discussion point. i'm looking into the drawbacks before we swap everything over given most methods use this now and i wouldn't want to make buildURI less robust for this single (sad) URL.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok. Let's do it in a safe way.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Definitely changing buildURI may lead to unpredictable bugs in other places

@jacobbednarz jacobbednarz merged commit e790799 into cloudflare:master Aug 11, 2022
@jacobbednarz
Copy link
Member

thanks!

@github-actions github-actions bot added this to the v0.47.0 milestone Aug 11, 2022
github-actions bot pushed a commit that referenced this pull request Aug 11, 2022
@github-actions
Copy link
Contributor

This functionality has been released in v0.47.0.

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you!

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.

Cannot remove cloudflare tunnel route which has vnet
3 participants