Skip to content

fix: resolve openai-compat provider fails when using IP:port base URL - #1090

Open
RerankerGuo wants to merge 1 commit into
agentscope-ai:mainfrom
RerankerGuo:fix/issue-1057-openai-compat-ip-port
Open

fix: resolve openai-compat provider fails when using IP:port base URL#1090
RerankerGuo wants to merge 1 commit into
agentscope-ai:mainfrom
RerankerGuo:fix/issue-1057-openai-compat-ip-port

Conversation

@RerankerGuo

Copy link
Copy Markdown
Contributor

Summary

This PR fixes #1057 by resolving three bugs in the openai-compat provider setup when using IP:port base URLs.

Changes

Bug 1: IP address now uses static service source (not DNS)

  • Added net.ParseIP() detection in both initializer.go and setup-higress.sh
  • IP addresses now correctly use static-type service source instead of DNS-type
  • Prevents Envoy DNS cluster resolution failures with bare IP addresses
  • Service name suffix changes from .dns to .static for IP-based hosts

Bug 2: openaiCustomUrl no longer includes port

  • Parse URL and reconstruct as scheme://host/path (without port)
  • Prevents polluting the upstream Host header and host-domain matching
  • Port is correctly configured only via openaiCustomServicePort

Bug 3: Idempotent GET→PUT updates for existing resources

  • ensureServiceSource, ensureStaticServiceSource, and EnsureAIProvider now use GET→PUT if exists / POST if not pattern
  • Matches the shell script's idempotent update behavior
  • Re-running the initializer correctly updates already-configured resources

Affected Files

  • agentteams-controller/internal/gateway/higress.go — GET→PUT pattern for service sources and AI providers
  • agentteams-controller/internal/initializer/initializer.go — IP detection + port stripping for openai-compat and default provider paths
  • manager/scripts/init/setup-higress.sh — Same fixes in shell script

Verification

  • gofmt -e syntax check passed for Go files
  • bash -n syntax check passed for shell script
  • Changelog entry added
  • All changes are backward compatible (domain-based DNS paths unchanged)

Closes agentscope-ai#1057
- Bug 1: Detect IP vs domain host and use static service source for IPs
  instead of DNS, preventing Envoy DNS cluster resolution failures
- Bug 2: Strip port from openaiCustomUrl (scheme://host/path only) to
  avoid polluting the upstream Host header and host-domain matching
- Bug 3: Implement GET→PUT if exists / POST if not idempotent updates
  for ensureServiceSource, ensureStaticServiceSource, and EnsureAIProvider
  so re-running the initializer correctly updates existing configs
- Apply same fixes to setup-higress.sh shell script

Test: gofmt -e (syntax check passed), bash -n (shell syntax OK)
@gemini-code-assist

Copy link
Copy Markdown

Caution

The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased.

@RerankerGuo
RerankerGuo force-pushed the fix/issue-1057-openai-compat-ip-port branch from cb0be30 to 07982e2 Compare July 30, 2026 00:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] openai-compat provider fails when using IP:port base URL

1 participant