fix(gateway): strip port from openai-compat openaiCustomUrl (#1057)#1061
fix(gateway): strip port from openai-compat openaiCustomUrl (#1057)#1061JOJOCrazy123 wants to merge 3 commits into
Conversation
Higress derives the upstream host domain from openaiCustomUrl, so an IP:port base URL such as http://10.43.46.12:3000/v1 produced host domain 10.43.46.12:3000, which is not a valid DNS hostname and broke resolution. Strip the port from openaiCustomUrl in the controller initializer and in setup-higress.sh, keeping scheme/host/path only. The port continues to be supplied via openaiCustomServicePort. Fixes agentscope-ai#1057
📊 CI Metrics ReportSummary
By Role
Per-Test Breakdown
TrendsGenerated by HiClaw CI on 2026-07-19 08:36:24 UTC |
CI note: the only red check (
|
|
Hi maintainers, this PR is ready for review, but the workflow is still awaiting maintainer approval. Could someone please approve the workflow and review the PR when convenient? Thank you! |
shiyiyue1102
left a comment
There was a problem hiding this comment.
Thanks for the focused fix. The IPv4 host:port case is handled, but customOpenAIURL currently reconstructs the URL from Scheme, Hostname, and the decoded Path, so it changes more than the port: it drops RawQuery, decodes escaped path segments, and emits unbracketed IPv6 literals. I reproduced all three cases locally.
Could you preserve the parsed URL and remove only the port, then add regression cases for query strings, escaped paths, and IPv6 literals? The existing controller unit and envtest integration suites pass locally; the red test-21 shard also fails on main and appears unrelated.
感谢这个聚焦的修复。当前 IPv4 host:port 场景已经处理,但 customOpenAIURL 通过 Scheme、Hostname 和解码后的 Path 重新拼装 URL,实际修改的不只是端口:它会丢失 RawQuery、解码转义路径,并生成没有方括号的 IPv6 URL。我已在本地复现这三种情况。
请保留解析后 URL 的其他字段,仅移除端口,并补充 query、转义路径和 IPv6 字面量的回归用例。现有 Controller 单元测试和 envtest 集成测试在本地均通过;红色的 test-21 分片在 main 上也失败,判断与本 PR 无关。
…-compat-custom-url-port # Conflicts: # agentteams-controller/internal/initializer/initializer_test.go # changelog/current.md
…om openaiCustomUrl Address review feedback on agentscope-ai#1061: customOpenAIURL reconstructed the URL from Scheme+Hostname+decoded Path, which dropped RawQuery, decoded escaped path segments, and emitted unbracketed IPv6 literals. Instead, keep the parsed URL and remove only the port (re-bracketing IPv6 hosts), so everything else is preserved. Add regression cases for query strings, escaped paths, and IPv6.
|
Thanks for the careful review — you're right on all three counts. I've reworked
Added regression cases for query strings, escaped paths ( I also merged latest Agreed the red |
Summary
Fixes #1057. When the
openai-compatLLM provider is configured with an IP:port base URL (e.g.http://10.43.46.12:3000/v1),openaiCustomUrlwas set to the full URL including the port. Higress derives the upstream host domain fromopenaiCustomUrl, so it extracted10.43.46.12:3000as the host domain — not a valid DNS hostname — and upstream DNS resolution failed, making the LLM endpoint unreachable.The port is already provided separately via
openaiCustomServicePort, so including it inopenaiCustomUrlis both redundant and breaking.Changes
hiclaw-controller/internal/initializer/initializer.go: addcustomOpenAIURL()helper that strips the port (keeps scheme/host/path) and use it foropenaiCustomUrlin both theopenai-compatand custom-provider paths.manager/scripts/init/setup-higress.sh: buildopenaiCustomUrlfrom scheme + domain + path only (no port).hiclaw-controller/internal/initializer/initializer_test.go: unit tests forcustomOpenAIURL.changelog/current.md: record the fix.Result:
openaiCustomUrlbecomeshttp://10.43.46.12/v1, host domain is10.43.46.12, and the port is supplied only viaopenaiCustomServicePort.Test plan
bash -n manager/scripts/init/setup-higress.shpasses; parsing verified for IP:port+path, host:port, no-port, and no-path inputs.go test ./internal/initializer/— could not run locally (no Go toolchain in this environment); expected to pass via CI.openai-compatprovider using an IP:port base URL and confirm the Higress provider "自定义 OpenAI 服务主机域" shows the host without the port.Notes
The issue also mentions a secondary bug where the Go
EnsureAIProvider/ensureServiceSourceuse POST-only (treating 409 as success) and cannot correct an already-misconfigured provider on re-run. That is a separate concern and intentionally left out of this narrow fix.