Skip to content

Commit

Permalink
fix PR
Browse files Browse the repository at this point in the history
  • Loading branch information
kingluo committed Jun 7, 2023
1 parent 0aa7c91 commit 0ed3b45
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions apisix/plugins/grpc-transcode/response.lua
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ local ipairs = ipairs
local pcall = pcall


local function handle_error_response(status_detail_type)
local function handle_error_response(status_detail_type, proto)
local err_msg

local grpc_status = ngx.header["grpc-status-details-bin"]
Expand Down Expand Up @@ -58,7 +58,9 @@ local function handle_error_response(status_detail_type)
if status_detail_type and details then
local decoded_details = {}
for _, detail in ipairs(details) do
local pb_old_state = pb.state(proto.pb_state)
local ok, err_or_value = pcall(pb.decode, status_detail_type, detail.value)
pb.state(pb_old_state)
if not ok then
err_msg = "failed to call pb.decode to decode details in "
.. "grpc-status-details-bin"
Expand Down Expand Up @@ -99,10 +101,7 @@ return function(ctx, proto, service, method, pb_option, show_status_in_body, sta

-- handle error response after the last response chunk
if ngx.status >= 300 and show_status_in_body then
local pb_old_state = pb.state(proto.pb_state)
local ret = handle_error_response(status_detail_type)
pb.state(pb_old_state)
return ret
return handle_error_response(status_detail_type, proto)
end

-- when body has already been read by other plugin
Expand Down

0 comments on commit 0ed3b45

Please sign in to comment.