You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by GitBox <gi...@apache.org> on 2021/04/14 07:21:12 UTC

[GitHub] [apisix-ingress-controller] okaybase opened a new pull request #374: fix: add compatibility logic for empty array when unmarshal json string to routeItem

okaybase opened a new pull request #374:
URL: https://github.com/apache/apisix-ingress-controller/pull/374


   Please answer these questions before submitting a pull request
   
   - Why submit this pull request?
   - [x] Bugfix
   - [ ] New feature provided
   - [ ] Improve performance
   - [ ] Backport patches
   
   - Related issues
   
   ___
   ### Bugfix
   - Description
   unmarshal json string to routeItem error when route info contains "vars":{}. 
   
   - How to fix?
   add compatibility logic for empty array when unmarshal json string to routeItem
   
   ___
   ### New feature or improvement
   - Describe the details and related test reports.
   
   ___
   ### Backport patches
   - Why need to backport?
   
   - Source branch
   
   - Related commits and pull requests
   
   - Target branch
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix-ingress-controller] okaybase commented on pull request #374: fix: add compatibility logic for empty array when unmarshal json string to route

Posted by GitBox <gi...@apache.org>.
okaybase commented on pull request #374:
URL: https://github.com/apache/apisix-ingress-controller/pull/374#issuecomment-820189583


   > 
   > 
   > @okaybase Now you can re-factor this PR.
   
   @tokers i have refactor this PR base on the #373 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix-ingress-controller] codecov-io edited a comment on pull request #374: fix: add compatibility logic for empty array when unmarshal json string to route

Posted by GitBox <gi...@apache.org>.
codecov-io edited a comment on pull request #374:
URL: https://github.com/apache/apisix-ingress-controller/pull/374#issuecomment-820184659


   # [Codecov](https://codecov.io/gh/apache/apisix-ingress-controller/pull/374?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
   > Merging [#374](https://codecov.io/gh/apache/apisix-ingress-controller/pull/374?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (53b8227) into [master](https://codecov.io/gh/apache/apisix-ingress-controller/commit/2da94e9d5d5d8d79a20ba7c6d095ea0965ee35e6?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (2da94e9) will **decrease** coverage by `0.18%`.
   > The diff coverage is `0.00%`.
   
   [![Impacted file tree graph](https://codecov.io/gh/apache/apisix-ingress-controller/pull/374/graphs/tree.svg?width=650&height=150&src=pr&token=WPLQXPY3V0&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)](https://codecov.io/gh/apache/apisix-ingress-controller/pull/374?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   
   ```diff
   @@            Coverage Diff             @@
   ##           master     #374      +/-   ##
   ==========================================
   - Coverage   40.04%   39.85%   -0.19%     
   ==========================================
     Files          38       37       -1     
     Lines        3109     3101       -8     
   ==========================================
   - Hits         1245     1236       -9     
   - Misses       1719     1720       +1     
     Partials      145      145              
   ```
   
   
   | [Impacted Files](https://codecov.io/gh/apache/apisix-ingress-controller/pull/374?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
   |---|---|---|
   | [pkg/apisix/route.go](https://codecov.io/gh/apache/apisix-ingress-controller/pull/374/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGtnL2FwaXNpeC9yb3V0ZS5nbw==) | `33.33% <0.00%> (-0.51%)` | :arrow_down: |
   | [pkg/kube/translation/ingress.go](https://codecov.io/gh/apache/apisix-ingress-controller/pull/374/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGtnL2t1YmUvdHJhbnNsYXRpb24vaW5ncmVzcy5nbw==) | `91.44% <0.00%> (-0.22%)` | :arrow_down: |
   | [pkg/kube/translation/apisix\_route.go](https://codecov.io/gh/apache/apisix-ingress-controller/pull/374/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGtnL2t1YmUvdHJhbnNsYXRpb24vYXBpc2l4X3JvdXRlLmdv) | `46.26% <0.00%> (-0.15%)` | :arrow_down: |
   | [pkg/kube/translation/apisix\_ssl.go](https://codecov.io/gh/apache/apisix-ingress-controller/pull/374/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGtnL2t1YmUvdHJhbnNsYXRpb24vYXBpc2l4X3NzbC5nbw==) | `0.00% <0.00%> (ø)` | |
   | [test/e2e/e2e.go](https://codecov.io/gh/apache/apisix-ingress-controller/pull/374/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-dGVzdC9lMmUvZTJlLmdv) | | |
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/apisix-ingress-controller/pull/374?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
   > Powered by [Codecov](https://codecov.io/gh/apache/apisix-ingress-controller/pull/374?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Last update [2da94e9...53b8227](https://codecov.io/gh/apache/apisix-ingress-controller/pull/374?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix-ingress-controller] okaybase commented on a change in pull request #374: fix: add compatibility logic for empty array when unmarshal json string to route

Posted by GitBox <gi...@apache.org>.
okaybase commented on a change in pull request #374:
URL: https://github.com/apache/apisix-ingress-controller/pull/374#discussion_r614025526



##########
File path: pkg/types/apisix/v1/types.go
##########
@@ -79,16 +79,37 @@ type Metadata struct {
 type Route struct {
 	Metadata `json:",inline" yaml:",inline"`
 
-	Host        string            `json:"host,omitempty" yaml:"host,omitempty"`
-	Hosts       []string          `json:"hosts,omitempty" yaml:"hosts,omitempty"`
-	Uri         string            `json:"uri,omitempty" yaml:"uri,omitempty"`
-	Priority    int               `json:"priority,omitempty" yaml:"priority,omitempty"`
-	Vars        [][]StringOrSlice `json:"vars,omitempty" yaml:"vars,omitempty"`
-	Uris        []string          `json:"uris,omitempty" yaml:"uris,omitempty"`
-	Methods     []string          `json:"methods,omitempty" yaml:"methods,omitempty"`
-	RemoteAddrs []string          `json:"remote_addrs,omitempty" yaml:"remote_addrs,omitempty"`
-	UpstreamId  string            `json:"upstream_id,omitempty" yaml:"upstream_id,omitempty"`
-	Plugins     Plugins           `json:"plugins,omitempty" yaml:"plugins,omitempty"`
+	Host        string   `json:"host,omitempty" yaml:"host,omitempty"`
+	Hosts       []string `json:"hosts,omitempty" yaml:"hosts,omitempty"`
+	Uri         string   `json:"uri,omitempty" yaml:"uri,omitempty"`
+	Priority    int      `json:"priority,omitempty" yaml:"priority,omitempty"`
+	Vars        Vars     `json:"vars,omitempty" yaml:"vars,omitempty"`
+	Uris        []string `json:"uris,omitempty" yaml:"uris,omitempty"`
+	Methods     []string `json:"methods,omitempty" yaml:"methods,omitempty"`
+	RemoteAddrs []string `json:"remote_addrs,omitempty" yaml:"remote_addrs,omitempty"`
+	UpstreamId  string   `json:"upstream_id,omitempty" yaml:"upstream_id,omitempty"`
+	Plugins     Plugins  `json:"plugins,omitempty" yaml:"plugins,omitempty"`
+}
+

Review comment:
       The comment for Vars type declare has been added.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix-ingress-controller] okaybase commented on a change in pull request #374: fix: add compatibility logic for empty array when unmarshal json string to route

Posted by GitBox <gi...@apache.org>.
okaybase commented on a change in pull request #374:
URL: https://github.com/apache/apisix-ingress-controller/pull/374#discussion_r614023947



##########
File path: pkg/apisix/resource_test.go
##########
@@ -74,3 +75,18 @@ func TestItemConvertRoute(t *testing.T) {
 	assert.Equal(t, r.Methods[1], "POST")
 	assert.Equal(t, r.Name, "unknown")
 }
+
+func TestRouteVarsUnmarshalJSONCompatibility(t *testing.T) {
+	var route v1.Route
+	data := `{"vars":{}}`
+	err := json.Unmarshal([]byte(data), &route)
+	assert.Nil(t, err)
+
+	data = `{"vars":{"a":"b"}}`
+	err = json.Unmarshal([]byte(data), &route)
+	assert.Equal(t, err.Error(), "unexpected non-empty object")
+
+	data = `{"vars":[]}`
+	err = json.Unmarshal([]byte(data), &route)
+	assert.Nil(t, err)

Review comment:
       The test case has been added.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix-ingress-controller] tokers commented on a change in pull request #374: fix: add compatibility logic for empty array when unmarshal json string to route

Posted by GitBox <gi...@apache.org>.
tokers commented on a change in pull request #374:
URL: https://github.com/apache/apisix-ingress-controller/pull/374#discussion_r613826770



##########
File path: pkg/apisix/resource.go
##########
@@ -72,6 +72,27 @@ type item struct {
 	Value json.RawMessage `json:"value"`
 }
 
+type routeWrap v1.Route

Review comment:
       You can just create a type `Vars` in `pkg/types/apisix/v1`, and Implement the `json.Unmarshaler` interface for it.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix-ingress-controller] codecov-io commented on pull request #374: fix: add compatibility logic for empty array when unmarshal json string to route

Posted by GitBox <gi...@apache.org>.
codecov-io commented on pull request #374:
URL: https://github.com/apache/apisix-ingress-controller/pull/374#issuecomment-820184659


   # [Codecov](https://codecov.io/gh/apache/apisix-ingress-controller/pull/374?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
   > Merging [#374](https://codecov.io/gh/apache/apisix-ingress-controller/pull/374?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (0efe3f7) into [master](https://codecov.io/gh/apache/apisix-ingress-controller/commit/2da94e9d5d5d8d79a20ba7c6d095ea0965ee35e6?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (2da94e9) will **decrease** coverage by `0.05%`.
   > The diff coverage is `71.42%`.
   
   [![Impacted file tree graph](https://codecov.io/gh/apache/apisix-ingress-controller/pull/374/graphs/tree.svg?width=650&height=150&src=pr&token=WPLQXPY3V0&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)](https://codecov.io/gh/apache/apisix-ingress-controller/pull/374?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   
   ```diff
   @@            Coverage Diff             @@
   ##           master     #374      +/-   ##
   ==========================================
   - Coverage   40.04%   39.98%   -0.06%     
   ==========================================
     Files          38       37       -1     
     Lines        3109     3111       +2     
   ==========================================
   - Hits         1245     1244       -1     
   - Misses       1719     1721       +2     
   - Partials      145      146       +1     
   ```
   
   
   | [Impacted Files](https://codecov.io/gh/apache/apisix-ingress-controller/pull/374?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
   |---|---|---|
   | [pkg/apisix/route.go](https://codecov.io/gh/apache/apisix-ingress-controller/pull/374/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGtnL2FwaXNpeC9yb3V0ZS5nbw==) | `33.33% <0.00%> (-0.51%)` | :arrow_down: |
   | [pkg/apisix/resource.go](https://codecov.io/gh/apache/apisix-ingress-controller/pull/374/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGtnL2FwaXNpeC9yZXNvdXJjZS5nbw==) | `57.77% <83.33%> (+6.34%)` | :arrow_up: |
   | [pkg/kube/translation/ingress.go](https://codecov.io/gh/apache/apisix-ingress-controller/pull/374/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGtnL2t1YmUvdHJhbnNsYXRpb24vaW5ncmVzcy5nbw==) | `91.44% <0.00%> (-0.22%)` | :arrow_down: |
   | [pkg/kube/translation/apisix\_route.go](https://codecov.io/gh/apache/apisix-ingress-controller/pull/374/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGtnL2t1YmUvdHJhbnNsYXRpb24vYXBpc2l4X3JvdXRlLmdv) | `46.26% <0.00%> (-0.15%)` | :arrow_down: |
   | [pkg/kube/translation/apisix\_ssl.go](https://codecov.io/gh/apache/apisix-ingress-controller/pull/374/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGtnL2t1YmUvdHJhbnNsYXRpb24vYXBpc2l4X3NzbC5nbw==) | `0.00% <0.00%> (ø)` | |
   | [test/e2e/e2e.go](https://codecov.io/gh/apache/apisix-ingress-controller/pull/374/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-dGVzdC9lMmUvZTJlLmdv) | | |
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/apisix-ingress-controller/pull/374?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
   > Powered by [Codecov](https://codecov.io/gh/apache/apisix-ingress-controller/pull/374?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Last update [2da94e9...0efe3f7](https://codecov.io/gh/apache/apisix-ingress-controller/pull/374?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix-ingress-controller] okaybase commented on a change in pull request #374: fix: add compatibility logic for empty array when unmarshal json string to route

Posted by GitBox <gi...@apache.org>.
okaybase commented on a change in pull request #374:
URL: https://github.com/apache/apisix-ingress-controller/pull/374#discussion_r614023947



##########
File path: pkg/apisix/resource_test.go
##########
@@ -74,3 +75,18 @@ func TestItemConvertRoute(t *testing.T) {
 	assert.Equal(t, r.Methods[1], "POST")
 	assert.Equal(t, r.Name, "unknown")
 }
+
+func TestRouteVarsUnmarshalJSONCompatibility(t *testing.T) {
+	var route v1.Route
+	data := `{"vars":{}}`
+	err := json.Unmarshal([]byte(data), &route)
+	assert.Nil(t, err)
+
+	data = `{"vars":{"a":"b"}}`
+	err = json.Unmarshal([]byte(data), &route)
+	assert.Equal(t, err.Error(), "unexpected non-empty object")
+
+	data = `{"vars":[]}`
+	err = json.Unmarshal([]byte(data), &route)
+	assert.Nil(t, err)

Review comment:
       The test case has been added!




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix-ingress-controller] tokers commented on pull request #374: fix: add compatibility logic for empty array when unmarshal json string to routeItem

Posted by GitBox <gi...@apache.org>.
tokers commented on pull request #374:
URL: https://github.com/apache/apisix-ingress-controller/pull/374#issuecomment-820126451


   @okaybase Now you can re-factor this PR.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix-ingress-controller] tokers commented on a change in pull request #374: fix: add compatibility logic for empty array when unmarshal json string to route

Posted by GitBox <gi...@apache.org>.
tokers commented on a change in pull request #374:
URL: https://github.com/apache/apisix-ingress-controller/pull/374#discussion_r613992168



##########
File path: pkg/types/apisix/v1/types.go
##########
@@ -79,16 +79,37 @@ type Metadata struct {
 type Route struct {
 	Metadata `json:",inline" yaml:",inline"`
 
-	Host        string            `json:"host,omitempty" yaml:"host,omitempty"`
-	Hosts       []string          `json:"hosts,omitempty" yaml:"hosts,omitempty"`
-	Uri         string            `json:"uri,omitempty" yaml:"uri,omitempty"`
-	Priority    int               `json:"priority,omitempty" yaml:"priority,omitempty"`
-	Vars        [][]StringOrSlice `json:"vars,omitempty" yaml:"vars,omitempty"`
-	Uris        []string          `json:"uris,omitempty" yaml:"uris,omitempty"`
-	Methods     []string          `json:"methods,omitempty" yaml:"methods,omitempty"`
-	RemoteAddrs []string          `json:"remote_addrs,omitempty" yaml:"remote_addrs,omitempty"`
-	UpstreamId  string            `json:"upstream_id,omitempty" yaml:"upstream_id,omitempty"`
-	Plugins     Plugins           `json:"plugins,omitempty" yaml:"plugins,omitempty"`
+	Host        string   `json:"host,omitempty" yaml:"host,omitempty"`
+	Hosts       []string `json:"hosts,omitempty" yaml:"hosts,omitempty"`
+	Uri         string   `json:"uri,omitempty" yaml:"uri,omitempty"`
+	Priority    int      `json:"priority,omitempty" yaml:"priority,omitempty"`
+	Vars        Vars     `json:"vars,omitempty" yaml:"vars,omitempty"`
+	Uris        []string `json:"uris,omitempty" yaml:"uris,omitempty"`
+	Methods     []string `json:"methods,omitempty" yaml:"methods,omitempty"`
+	RemoteAddrs []string `json:"remote_addrs,omitempty" yaml:"remote_addrs,omitempty"`
+	UpstreamId  string   `json:"upstream_id,omitempty" yaml:"upstream_id,omitempty"`
+	Plugins     Plugins  `json:"plugins,omitempty" yaml:"plugins,omitempty"`
+}
+

Review comment:
       Add a comment for it.
   
   ```suggestion
   // Vars represents the route match expressions of APISIX.
   type Vars [][]StringOrSlice
   ```

##########
File path: pkg/apisix/resource_test.go
##########
@@ -74,3 +75,18 @@ func TestItemConvertRoute(t *testing.T) {
 	assert.Equal(t, r.Methods[1], "POST")
 	assert.Equal(t, r.Name, "unknown")
 }
+
+func TestRouteVarsUnmarshalJSONCompatibility(t *testing.T) {
+	var route v1.Route
+	data := `{"vars":{}}`
+	err := json.Unmarshal([]byte(data), &route)
+	assert.Nil(t, err)
+
+	data = `{"vars":{"a":"b"}}`
+	err = json.Unmarshal([]byte(data), &route)
+	assert.Equal(t, err.Error(), "unexpected non-empty object")
+
+	data = `{"vars":[]}`
+	err = json.Unmarshal([]byte(data), &route)
+	assert.Nil(t, err)

Review comment:
       Also add a normal case where `vars` is a non-empty slice.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix-ingress-controller] tokers commented on pull request #374: fix: add compatibility logic for empty array when unmarshal json string to route

Posted by GitBox <gi...@apache.org>.
tokers commented on pull request #374:
URL: https://github.com/apache/apisix-ingress-controller/pull/374#issuecomment-820424691


   @okaybase Merged, many thanks!


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix-ingress-controller] tokers merged pull request #374: fix: add compatibility logic for empty array when unmarshal json string to route

Posted by GitBox <gi...@apache.org>.
tokers merged pull request #374:
URL: https://github.com/apache/apisix-ingress-controller/pull/374


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix-ingress-controller] okaybase commented on a change in pull request #374: fix: add compatibility logic for empty array when unmarshal json string to route

Posted by GitBox <gi...@apache.org>.
okaybase commented on a change in pull request #374:
URL: https://github.com/apache/apisix-ingress-controller/pull/374#discussion_r613864374



##########
File path: pkg/apisix/resource.go
##########
@@ -72,6 +72,27 @@ type item struct {
 	Value json.RawMessage `json:"value"`
 }
 
+type routeWrap v1.Route

Review comment:
       Yes, thanks for your suggestion! I have rewrite.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org