fix(plugins): add old_default to redis shorthand fields to prevent spurious deprecation warnings #14804
+20
−10
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR fixes an issue where
rate-limitingandresponse-ratelimitingplugins were generating excessive deprecation warnings even when users never configured any redis-related parameters.Root Cause Analysis:
redis.*field values back to deprecatedredis_*shorthand fields (for backwards compatibility)redis.*fields have default values (e.g.,ssl=false,port=6379,timeout=2000,database=0)redis_*fields on every config readredis_*shorthand field definitions lackedold_defaultvalues, every value (including defaults) triggered deprecation warningskong/db/schema/metaschema.lua:old_defaultis not set, the warning is always printedold_defaultis set, the warning is only printed when the value differs fromold_defaultThe Fix:
Added
old_defaultvalues to shorthand fields that have corresponding defaults inredis.*:redis_port6379redis_sslfalseredis_ssl_verifyfalseredis_timeout2000redis_database0Fields without defaults (
redis_host,redis_password,redis_username,redis_server_name) don't needold_defaultasnilvalues don't trigger the reverse mapping.Before this fix:
(Logged on every request, even when user never configured redis)
After this fix:
redis_*config with non-default valuesRelated Issue
Fixes #14418
Test Plan
spec/03-plugins/23-rate-limiting/05-integration_spec.luaandspec/03-plugins/24-response-rate-limiting/05-integration_spec.luaverify:redis.*config format → no deprecation warningsredis_*config with non-default values → deprecation warnings appear