Skip to content

Conversation

@alexezio
Copy link

Summary

This PR fixes an issue where rate-limiting and response-ratelimiting plugins were generating excessive deprecation warnings even when users never configured any redis-related parameters.

Root Cause Analysis:

  1. When reading plugin configuration, Kong reverse-maps the new redis.* field values back to deprecated redis_* shorthand fields (for backwards compatibility)
  2. The redis.* fields have default values (e.g., ssl=false, port=6379, timeout=2000, database=0)
  3. These default values get reverse-mapped to redis_* fields on every config read
  4. Since the redis_* shorthand field definitions lacked old_default values, every value (including defaults) triggered deprecation warnings
  5. According to kong/db/schema/metaschema.lua:
    • If old_default is not set, the warning is always printed
    • If old_default is set, the warning is only printed when the value differs from old_default

The Fix:

Added old_default values to shorthand fields that have corresponding defaults in redis.*:

Field old_default
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.

Before this fix:

[kong] init.lua:904 rate-limiting: config.redis_ssl is deprecated, please use config.redis.ssl instead

(Logged on every request, even when user never configured redis)

After this fix:

  • No deprecation warnings when using default values
  • Warnings still appear when users explicitly use deprecated redis_* config with non-default values

Related Issue

Fixes #14418

Test Plan

  • Existing integration tests in spec/03-plugins/23-rate-limiting/05-integration_spec.lua and spec/03-plugins/24-response-rate-limiting/05-integration_spec.lua verify:
    • Using new redis.* config format → no deprecation warnings
    • Using legacy redis_* config with non-default values → deprecation warnings appear
  • Manual verification: Create rate-limiting plugin without any redis config, confirm no deprecation warnings in logs

…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
@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

1 similar comment
@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Upgrade from Kong 3.8.0 to 3.9.0 rate-limiting plugin depreciation warning

3 participants