-
Notifications
You must be signed in to change notification settings - Fork 2.7k
test: cover grpc-transcode empty array responses #12649
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
base: master
Are you sure you want to change the base?
Changes from 3 commits
aa7741f
6aac6c5
5a48b4b
8447a30
cfbd662
4be5275
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -23,6 +23,47 @@ local string = string | |||||||||
| local ngx_decode_base64 = ngx.decode_base64 | ||||||||||
| local ipairs = ipairs | ||||||||||
| local pcall = pcall | ||||||||||
| local type = type | ||||||||||
| local pairs = pairs | ||||||||||
| local setmetatable = setmetatable | ||||||||||
|
|
||||||||||
| -- Protobuf repeated field label value | ||||||||||
| local PROTOBUF_REPEATED_LABEL = 3 | ||||||||||
| local repeated_label = PROTOBUF_REPEATED_LABEL | ||||||||||
|
|
||||||||||
| local function fetch_proto_array_names(proto_obj) | ||||||||||
| local names = {} | ||||||||||
| if type(proto_obj) == "table" then | ||||||||||
|
||||||||||
| if type(proto_obj) == "table" then | |
| if type(proto_obj) ~= "table" then | |
| return | |
| end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fetch_proto_array_names always returns a table so that its callers can safely iterate with pairs(sub_names). Returning nil for the base case would trigger a runtime error when pairs(nil) is evaluated, and it would not change correctness because the existing code already skips non-table values
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| names[sub_name] = 1 | |
| names[sub_name] = true |
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can cache it without having to reprocess it every time a request is made.
| local function create_proto_obj(proto_id) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function does not take into account the possibility of duplicate names in nested fields, for example: