Skip to content

fix(resource): add plugin_configs support for fetch_latest_conf, fix ai-proxy-multi plugin with multi instance not support plugin_config_id#13458

Open
chryancclee-boop wants to merge 3 commits into
apache:masterfrom
chryancclee-boop:master
Open

Conversation

@chryancclee-boop
Copy link
Copy Markdown

@chryancclee-boop chryancclee-boop commented May 30, 2026

When the ai-proxy-multi plugin uses plugin_config_id to reference a PluginConfig containing multiple instances, APISIX returns a 503 error: "fetch_latest_conf(): unsupported resource type: plugin_configs".

Root cause:

  • pick_target() in ai-proxy-multi.lua calls resource.fetch_latest_conf() to fetch the parent configuration for load balancing and health checking.
  • When referencing via plugin_config_id, the _meta.parent.resource_key is set to "/plugin_configs/".
  • resource.fetch_latest_conf() previously only supported upstreams, routes, services, and stream_routes, causing it to reject "plugin_configs".

Why single instance works:

  • Single instance scenarios bypass pick_target() entirely since no load balancing is needed, so resource.fetch_latest_conf() is never invoked.

Fix:

Verification:

  • Single instance + plugin_config_id: 200 (unchanged)
  • Multi-instance + plugin_config_id: 503 -> 200 (fixed)
  • Multi-instance + embedded plugins: 200 (unchanged)

Checklist

  • I have explained the need for this PR and the problem it solves
  • I have explained the changes or the new features added to this PR
  • I have added tests corresponding to this change
  • I have updated the documentation to reflect this change
  • I have verified that this change is backward compatible (If not, please discuss on the APISIX mailing list first)

When the ai-proxy-multi plugin uses plugin_config_id to reference a
PluginConfig containing multiple instances, APISIX returns a 503 error:
"fetch_latest_conf(): unsupported resource type: plugin_configs".

Root cause:
- pick_target() in ai-proxy-multi.lua calls resource.fetch_latest_conf()
  to fetch the parent configuration for load balancing and health checking.
- When referencing via plugin_config_id, the _meta.parent.resource_key
  is set to "/plugin_configs/<id>".
- resource.fetch_latest_conf() previously only supported upstreams,
  routes, services, and stream_routes, causing it to reject "plugin_configs".

Why single instance works:
- Single instance scenarios bypass pick_target() entirely since no load
  balancing is needed, so resource.fetch_latest_conf() is never invoked.

Fix:
- Add "plugin_configs" to the supported resource types in resource.lua.

Verification:
- Single instance + plugin_config_id: 200 (unchanged)
- Multi-instance + plugin_config_id: 503 -> 200 (fixed)
- Multi-instance + embedded plugins: 200 (unchanged)

Signed-off-by: lichunhan <chryancc.lee@gmail.com>
@dosubot dosubot Bot added size:XS This PR changes 0-9 lines, ignoring generated files. bug Something isn't working labels May 30, 2026
When the ai-proxy-multi plugin uses plugin_config_id to reference a
PluginConfig containing multiple instances, APISIX returns a 503 error:
"fetch_latest_conf(): unsupported resource type: plugin_configs".

Root cause:
- pick_target() in ai-proxy-multi.lua calls resource.fetch_latest_conf()
  to fetch the parent configuration for load balancing and health checking.
- When referencing via plugin_config_id, the _meta.parent.resource_key
  is set to "/plugin_configs/<id>".
- resource.fetch_latest_conf() previously only supported upstreams,
  routes, services, and stream_routes, causing it to reject "plugin_configs".

Why single instance works:
- Single instance scenarios bypass pick_target() entirely since no load
  balancing is needed, so resource.fetch_latest_conf() is never invoked.

Fix:
- Add "plugin_configs" to the supported resource types in resource.lua.

Verification:
- Single instance + plugin_config_id: 200 (unchanged)
- Multi-instance + plugin_config_id: 503 -> 200 (fixed)
- Multi-instance + embedded plugins: 200 (unchanged)

Signed-off-by: lichunhan <chryancc.lee@gmail.com>
Copy link
Copy Markdown
Contributor

@Baoyuantop Baoyuantop left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please provide the corresponding test cases.

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

Labels

bug Something isn't working size:XS This PR changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants