Skip to content

Commit f1018cc

Browse files
authored
fix: downgrade decrypt failure log from warn to info (#13324)
1 parent bda084d commit f1018cc

1 file changed

Lines changed: 14 additions & 8 deletions

File tree

apisix/plugin.lua

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -993,7 +993,13 @@ end
993993
-- - Arbitrary depth dotted paths (e.g., "a.b.c.d")
994994
-- - Array traversal at intermediate nodes (iterate each element)
995995
-- - Leaf type dispatch: string, array of strings, map of strings
996+
local decrypt_hint = ". This can happen after upgrading if the field was recently "
997+
.. "added to encrypt_fields; if the value was encrypted, verify the data_encryption "
998+
.. "keyring. Re-save the configuration via the Admin API to resolve."
999+
9961000
local function process_encrypt_field(conf, key_path, operation, plugin_name, op_name)
1001+
local log_func = op_name == "decrypt" and core.log.info or core.log.warn
1002+
local hint = op_name == "decrypt" and decrypt_hint or ""
9971003
local dot_pos = core.string.find(key_path, ".")
9981004

9991005
if not dot_pos then
@@ -1006,8 +1012,8 @@ local function process_encrypt_field(conf, key_path, operation, plugin_name, op_
10061012
if type(val) == "string" then
10071013
local result, err = operation(val, "data_encrypt")
10081014
if not result then
1009-
core.log.warn("failed to ", op_name, " the conf of plugin [",
1010-
plugin_name, "] key [", key_path, "], err: ", err)
1015+
log_func("failed to ", op_name, " the conf of plugin [",
1016+
plugin_name, "] key [", key_path, "], err: ", err, hint)
10111017
else
10121018
conf[key_path] = result
10131019
end
@@ -1019,9 +1025,9 @@ local function process_encrypt_field(conf, key_path, operation, plugin_name, op_
10191025
if type(item) == "string" then
10201026
local result, err = operation(item, "data_encrypt")
10211027
if not result then
1022-
core.log.warn("failed to ", op_name, " the conf of plugin [",
1023-
plugin_name, "] key [", key_path,
1024-
"] index [", i, "], err: ", err)
1028+
log_func("failed to ", op_name, " the conf of plugin [",
1029+
plugin_name, "] key [", key_path,
1030+
"] index [", i, "], err: ", err, hint)
10251031
else
10261032
val[i] = result
10271033
end
@@ -1033,9 +1039,9 @@ local function process_encrypt_field(conf, key_path, operation, plugin_name, op_
10331039
if type(v) == "string" then
10341040
local result, err = operation(v, "data_encrypt")
10351041
if not result then
1036-
core.log.warn("failed to ", op_name, " the conf of plugin [",
1037-
plugin_name, "] key [", key_path,
1038-
".", k, "], err: ", err)
1042+
log_func("failed to ", op_name, " the conf of plugin [",
1043+
plugin_name, "] key [", key_path,
1044+
".", k, "], err: ", err, hint)
10391045
else
10401046
val[k] = result
10411047
end

0 commit comments

Comments
 (0)