fix: handle empty string for CAPTAIN_OPEN_AI_ENDPOINT config (#12435)

When CAPTAIN_OPEN_AI_ENDPOINT is set to empty string, use .presence to
properly fall back to default OpenAI endpoint instead of creating
malformed URLs.

Fixes #12383

Co-authored-by: Pranav <pranav@chatwoot.com>
This commit is contained in:
Aman Kumar
2025-09-16 06:18:18 +05:30
committed by GitHub
parent 3496764576
commit 211d071832

View File

@@ -81,7 +81,7 @@ class Integrations::OpenaiBaseService
end
def api_url
endpoint = InstallationConfig.find_by(name: 'CAPTAIN_OPEN_AI_ENDPOINT')&.value || 'https://api.openai.com/'
endpoint = InstallationConfig.find_by(name: 'CAPTAIN_OPEN_AI_ENDPOINT')&.value.presence || 'https://api.openai.com/'
endpoint = endpoint.chomp('/')
"#{endpoint}/v1/chat/completions"
end