This is an automated email from the ASF dual-hosted git repository.
shreemaan-abhishek 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 9166556f5 fix(gcp): report auth_file path instead of file contents in
parse error (#13409)
9166556f5 is described below
commit 9166556f52344b8156f0764ee2e3a8c38e7f0b61
Author: Shreemaan Abhishek <[email protected]>
AuthorDate: Mon May 25 11:24:46 2026 +0800
fix(gcp): report auth_file path instead of file contents in parse error
(#13409)
---
apisix/plugins/google-cloud-logging.lua | 2 +-
apisix/secret/gcp.lua | 2 +-
t/secret/conf/invalid.json | 1 +
t/secret/gcp.t | 26 ++++++++++++++++++++++++++
4 files changed, 29 insertions(+), 2 deletions(-)
diff --git a/apisix/plugins/google-cloud-logging.lua
b/apisix/plugins/google-cloud-logging.lua
index 09d6eb5f9..39202e521 100644
--- a/apisix/plugins/google-cloud-logging.lua
+++ b/apisix/plugins/google-cloud-logging.lua
@@ -170,7 +170,7 @@ local function fetch_oauth_conf(conf)
local config_tab
config_tab, err = core.json.decode(file_content)
if not config_tab then
- return nil, "config parse failure, data: " .. file_content .. " , err:
" .. err
+ return nil, "config parse failure, file: " .. conf.auth_file .. ",
err: " .. err
end
return config_tab
diff --git a/apisix/secret/gcp.lua b/apisix/secret/gcp.lua
index 6b6e661c4..9135582d0 100644
--- a/apisix/secret/gcp.lua
+++ b/apisix/secret/gcp.lua
@@ -83,7 +83,7 @@ local function fetch_oauth_conf(conf)
local config_tab, err = core.json.decode(file_content)
if not config_tab then
- return nil, "config parse failure, data: " .. file_content .. ", err:
" .. err
+ return nil, "config parse failure, file: " .. conf.auth_file .. ",
err: " .. err
end
local config = {
diff --git a/t/secret/conf/invalid.json b/t/secret/conf/invalid.json
new file mode 100644
index 000000000..afe4c74b1
--- /dev/null
+++ b/t/secret/conf/invalid.json
@@ -0,0 +1 @@
+gcp-service-account-placeholder
diff --git a/t/secret/gcp.t b/t/secret/gcp.t
index b7fc5331c..1ffed75d7 100644
--- a/t/secret/gcp.t
+++ b/t/secret/gcp.t
@@ -735,3 +735,29 @@ kEJQcmfVew5mFXyxuEn3zA==
GET /t
--- response_body
err
+
+
+
+=== TEST 15: get value from gcp by auth_file(invalid json content)
+--- config
+ location /t {
+ content_by_lua_block {
+ local conf = {
+ auth_file = "t/secret/conf/invalid.json",
+ }
+ local gcp = require("apisix.secret.gcp")
+ local value, err = gcp.get(conf, "jack/key")
+ if value then
+ return ngx.say(value)
+ end
+ if err:find("file: t/secret/conf/invalid.json", 1, true) then
+ ngx.say("path reported")
+ else
+ ngx.say(err)
+ end
+ }
+ }
+--- request
+GET /t
+--- response_body
+path reported