Skip to content

fix(ai-proxy): catch malformed override endpoint in schema validation#12563

Merged
Revolyssup merged 1 commit into
apache:masterfrom
Revolyssup:revolyssup/add-schema
Aug 30, 2025
Merged

fix(ai-proxy): catch malformed override endpoint in schema validation#12563
Revolyssup merged 1 commit into
apache:masterfrom
Revolyssup:revolyssup/add-schema

Conversation

@Revolyssup

@Revolyssup Revolyssup commented Aug 29, 2025

Copy link
Copy Markdown
Contributor

I noticed that when invalid url is passed in override endpoint like "http//localhost:8080" (here : is missing). The ai configuration is still accepted.
But later error comes in user request path and user gets 500
Screenshot 2025-08-29 at 12 04 55 PM

This PR adds endpoint validation during schema check.

  • 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)

@dosubot dosubot Bot added size:M This PR changes 30-99 lines, ignoring generated files. bug Something isn't working labels Aug 29, 2025
local type = type

local priority_balancer = require("apisix.balancer.priority")
local endpoint_regex = "^(https?)://([^:/]+):?(%d*)/?.*$"

@bzp2010 bzp2010 Aug 29, 2025

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Are you sure this is correct?

  1. The / appears to be unescaped. If the Lua string "xxx" can avoid this issue, please disregard.
  2. %d seems to cause backtracking and result in a failed match? Whereas \d matches correctly.

I'm using https://regex101.com PCRE2 mode to check it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I guess its parsed differently in the website vs the lua code.

  1. is no issue. its parsed correctly as can be confirmed by tests.
  2. It does match otherwise tests would be failing.

@Revolyssup
Revolyssup merged commit c25aff9 into apache:master Aug 30, 2025
43 of 44 checks passed
@Revolyssup
Revolyssup deleted the revolyssup/add-schema branch August 30, 2025 15:52
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:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants