Skip to content

Commit

Permalink
fix(llm): fix error when upstream_url missing trailing slash (#14186)
Browse files Browse the repository at this point in the history
  • Loading branch information
fffonion authored Feb 7, 2025
1 parent e950249 commit b1d10c4
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
message: |
**AI Plugins**: Fixed AI upstream URL trailing being empty.
type: bugfix
scope: Plugin
2 changes: 1 addition & 1 deletion kong/llm/drivers/anthropic.lua
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,7 @@ function _M.configure_request(conf)
ai_shared.override_upstream_url(parsed_url, conf)

-- if the path is read from a URL capture, ensure that it is valid
parsed_url.path = string_gsub(parsed_url.path, "^/*", "/")
parsed_url.path = (parsed_url.path and string_gsub(parsed_url.path, "^/*", "/")) or "/"

kong.service.request.set_path(parsed_url.path)
kong.service.request.set_scheme(parsed_url.scheme)
Expand Down
2 changes: 1 addition & 1 deletion kong/llm/drivers/azure.lua
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ function _M.configure_request(conf)
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, "^/*", "/")
parsed_url.path = (parsed_url.path and string_gsub(parsed_url.path, "^/*", "/")) or "/"

kong.service.request.set_path(parsed_url.path)
kong.service.request.set_scheme(parsed_url.scheme)
Expand Down
2 changes: 1 addition & 1 deletion kong/llm/drivers/bedrock.lua
Original file line number Diff line number Diff line change
Expand Up @@ -568,7 +568,7 @@ function _M.configure_request(conf, aws_sdk)
end

-- if the path is read from a URL capture, ensure that it is valid
parsed_url.path = string_gsub(parsed_url.path, "^/*", "/")
parsed_url.path = (parsed_url.path and string_gsub(parsed_url.path, "^/*", "/")) or "/"

ai_shared.override_upstream_url(parsed_url, conf)

Expand Down
2 changes: 1 addition & 1 deletion kong/llm/drivers/cohere.lua
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,7 @@ function _M.configure_request(conf)


-- if the path is read from a URL capture, ensure that it is valid
parsed_url.path = string_gsub(parsed_url.path, "^/*", "/")
parsed_url.path = (parsed_url.path and string_gsub(parsed_url.path, "^/*", "/")) or "/"

kong.service.request.set_path(parsed_url.path)
kong.service.request.set_scheme(parsed_url.scheme)
Expand Down
2 changes: 1 addition & 1 deletion kong/llm/drivers/gemini.lua
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,7 @@ function _M.configure_request(conf, identity_interface)


-- if the path is read from a URL capture, ensure that it is valid
parsed_url.path = string_gsub(parsed_url.path, "^/*", "/")
parsed_url.path = (parsed_url.path and string_gsub(parsed_url.path, "^/*", "/")) or "/"

kong.service.request.set_path(parsed_url.path)
kong.service.request.set_scheme(parsed_url.scheme)
Expand Down
2 changes: 1 addition & 1 deletion kong/llm/drivers/openai.lua
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ function _M.configure_request(conf)
ai_shared.override_upstream_url(parsed_url, conf)

-- if the path is read from a URL capture, ensure that it is valid
parsed_url.path = string_gsub(parsed_url.path, "^/*", "/")
parsed_url.path = (parsed_url.path and string_gsub(parsed_url.path, "^/*", "/")) or "/"

kong.service.request.set_path(parsed_url.path)
kong.service.request.set_scheme(parsed_url.scheme)
Expand Down

1 comment on commit b1d10c4

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

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

Bazel Build

Docker image available kong/kong-dev:b1d10c4627166338ea00da01d45462ecf817eabe
Artifacts available https://github.com/Kong/kong/actions/runs/13196349784

Please sign in to comment.