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-15 17:48:18 -07:00
committed by GitHub
co-authored by Pranav
parent 3496764576
commit 211d071832
+1 -1
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