This is an automated email from the ASF dual-hosted git repository.

spacewander pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix.git


The following commit(s) were added to refs/heads/master by this push:
     new b498e98ff change(grpc): map grpc code OUT_OF_RANGE to http code 400 
(#7419)
b498e98ff is described below

commit b498e98fff5e19a5e927d3ba25d9d9219a062356
Author: vyvyan2010 <375636...@qq.com>
AuthorDate: Wed Jul 13 09:56:22 2022 +0800

    change(grpc): map grpc code OUT_OF_RANGE to http code 400 (#7419)
---
 apisix/plugins/grpc-transcode.lua | 25 +++++++++++++++++--------
 1 file changed, 17 insertions(+), 8 deletions(-)

diff --git a/apisix/plugins/grpc-transcode.lua 
b/apisix/plugins/grpc-transcode.lua
index 7da62a805..2405d33ec 100644
--- a/apisix/plugins/grpc-transcode.lua
+++ b/apisix/plugins/grpc-transcode.lua
@@ -77,15 +77,24 @@ local schema = {
     required = { "proto_id", "service", "method" },
 }
 
+-- Based on https://cloud.google.com/apis/design/errors#handling_errors
 local status_rel = {
-    ["3"] = 400,
-    ["4"] = 504,
-    ["5"] = 404,
-    ["7"] = 403,
-    ["11"] = 416,
-    ["12"] = 501,
-    ["13"] = 500,
-    ["14"] = 503,
+    ["1"] = 499,    -- CANCELLED
+    ["2"] = 500,    -- UNKNOWN
+    ["3"] = 400,    -- INVALID_ARGUMENT
+    ["4"] = 504,    -- DEADLINE_EXCEEDED
+    ["5"] = 404,    -- NOT_FOUND
+    ["6"] = 409,    -- ALREADY_EXISTS
+    ["7"] = 403,    -- PERMISSION_DENIED
+    ["8"] = 429,    -- RESOURCE_EXHAUSTED
+    ["9"] = 400,    -- FAILED_PRECONDITION
+    ["10"] = 409,   -- ABORTED
+    ["11"] = 400,   -- OUT_OF_RANGE
+    ["12"] = 501,   -- UNIMPLEMENTED
+    ["13"] = 500,   -- INTERNAL
+    ["14"] = 503,   -- UNAVAILABLE
+    ["15"] = 500,   -- DATA_LOSS
+    ["16"] = 401,   -- UNAUTHENTICATED
 }
 
 local _M = {

Reply via email to