Skip to content

Can plugin configurations support "inheritance" from higher levels with partial property overrides, instead of complete replacement? #12921

@hlg212

Description

@hlg212

Description

I want to define a common configuration template for certain plugins (e.g., limit-count) that includes basic connection information (such as Redis host and port). When enabling the plugin on a route, I expect these basic properties to be automatically filled, while allowing the route to override specific properties (such as rate-limiting rules), rather than completely rewriting the entire plugin configuration.

I have tried using Plugin Config and Plugin Metadata, but their behavior does not meet expectations:

  • Plugin Metadata: Requires internal plugin support and is not a general solution.
  • Conflict between Plugin Config and Route Configuration: According to the official documentation, when the same plugin is configured across multiple objects (e.g., Route and Plugin Config), merging follows the priority order Consumer > Route > Plugin Config > Service. However, only the complete configuration of the highest-priority plugin instance is executed. This means the route configuration entirely replaces the Plugin Config configuration, rather than performing intelligent property-level merging and overriding.

Reproduction Steps and Current Result:

  1. Create a Plugin Config containing limit-count connection information.
  2. Create a route that references plugin_config_id: test-plugin_config_id and configures the limit-count plugin in the plugins field, specifying only different rate-limiting properties.

Example Configuration:

{
  "time_window": 60,
  "redis_host": "local",
  "count": 5
}

Plugin Config Configuration:

{
  "rejected_msg": "plugin configs !",
  "time_window": 60,
  "redis_host": "local",
  "count": 2
}
  1. Test the route and observe that the plugin uses the route configuration but loses the "rejected_msg" information defined in the Plugin Config, resulting in a direct 503 error page (see screenshot: [image placeholder]).
Image

Expected Behavior:
I expect plugin configurations to support an "inheritance" or "default value filling" model. For example, with Redis plugins, the expected merging logic would be:

  • Higher level (e.g., Plugin Config): Defines default/basic properties (host, port, password).
  • Lower level (e.g., Route): Defines extended or overridden properties (database, timeout).

Final effective configuration: Properties specified at the lower level override those of the same name at the higher level, while unique properties from the higher level are automatically included. Example:
{host, port, password} + {database, timeout} → {host, port, password, database, timeout}.

My Questions:

  1. In the current APISIX design, is there a way to achieve the "property-level merging" described above?
  2. If not currently available, does the official team plan to support such functionality in future versions (e.g., enhancing the merging strategy for Plugin Config)?

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionlabel for questions asked by users

    Type

    No type

    Projects

    Status

    📋 Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions