fix(plugins): add old_default to redis shorthand fields to prevent spurious deprecation warnings#14804
Open
alexezio wants to merge 1 commit intoKong:masterfrom
Open
Conversation
|
|
…urious deprecation warnings When using rate-limiting or response-ratelimiting plugins without explicitly configuring redis_* parameters, users were seeing deprecation warnings on every request. This happened because: 1. The redis.* fields have default values (e.g., ssl=false, port=6379) 2. On config read, these defaults were reverse-mapped to deprecated redis_* fields 3. Since redis_* shorthand fields lacked old_default, every value triggered warnings This fix adds old_default values matching the redis.* field defaults: - redis_port: 6379 - redis_ssl: false - redis_ssl_verify: false - redis_timeout: 2000 - redis_database: 0 Fields without defaults (redis_host, redis_password, redis_username, redis_server_name) don't need old_default as nil values don't trigger the reverse mapping. Fixes Kong#14418
aadd7fd to
c4ce1e2
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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