-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(ai): (FTI-6403) Fixed error with Azure path override formatting #14051
base: master
Are you sure you want to change the base?
Conversation
9c0c579
to
bedbcc7
Compare
kong/llm/drivers/azure.lua
Outdated
ai_shared.override_upstream_url(parsed_url, conf) | ||
|
||
-- if the path is read from a URL capture, 3re that it is valid | ||
parsed_url.path = string_gsub(parsed_url.path, "^/*", "/") | ||
kong.log.warn("JJ: ", parsed_url.path) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's remove the debug line.
@@ -118,10 +118,18 @@ function _M.configure_request(conf) | |||
parsed_url = socket_url.parse(url) | |||
end | |||
|
|||
-- if the path is read from a URL capture, ensure that it is valid | |||
parsed_url.path = string_gsub(parsed_url.path, "^/*", "/") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for what case? it seems not possible to get a dirty URL path.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was added because it was reported that it broke when you set like this:
config:
model:
options:
upstream_url: http://localhost:8080
for example.
I don't want to remove this, it was to fix a very specific issue for someone.
-- Azure-specific - prepend the deployment instance path to the | ||
-- user-override path. | ||
if conf.model.options and conf.model.options.upstream_path then | ||
conf.model.options.upstream_path = parsed_url.path |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The dynamic change conf in runtime is wired for me. we need to rebuilt route in here I think
if conf.model.options.upstream_url then
parsed_url = socket_url.parse(conf.model.options.upstream_url)
else
-- azure has non-standard URL format
local url = fmt(
"%s%s",
ai_shared.upstream_url_format[DRIVER_NAME]:format(conf.model.options.azure_instance, conf.model.options.azure_deployment_id),
conf.model.options
and conf.model.options.upstream_path
or ai_shared.operation_map[DRIVER_NAME][conf.route_type]
and ai_shared.operation_map[DRIVER_NAME][conf.route_type].path
or "/"
)
parsed_url = socket_url.parse(url)
end
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@oowl I don't understand the proposal :( can you just push the change in and run the CI?
My tests absolutely 100% covers the client's issue now.
Summary
There was a bug found, where the Azure provider stopped parsing 'custom upstream path' overrides since Kong 3.9.0.
Every request would 404 due to incorrect parsing.
I've added a parser / config options test to prevent this from happening again!
Checklist
changelog/unreleased/kong
orskip-changelog
label added on PR if changelog is unnecessary. README.mdIssue reference
FTI-6403
AG-191