fix(openai_compat): log warning instead of silently discarding native_search ok check

Replace the no-op _ = ok with a warning log when native_search has an
unexpected type. When the type assertion fails, nativeSearch already
defaults to false, which is conservative — but the caller should know
their option was malformed.
This commit is contained in:
程智超0668000959 2026-06-12 11:23:13 +08:00
parent 351ecf0182
commit 409cc051e7

View file

@ -155,7 +155,14 @@ func (p *Provider) buildRequestBody(
// When fallback uses a different provider (e.g. DeepSeek), that provider must not inject web_search_preview. // When fallback uses a different provider (e.g. DeepSeek), that provider must not inject web_search_preview.
nativeSearch, ok := options["native_search"].(bool) nativeSearch, ok := options["native_search"].(bool)
_ = ok if !ok {
// If the option is present but not a bool, log a warning and
// treat it as false — web_search_preview must not be injected
// when the caller cannot express a well-typed intent.
if _, present := options["native_search"]; present {
log.Printf("[openai_compat] native_search option has unexpected type %T, ignoring", options["native_search"])
}
}
nativeSearch = nativeSearch && isNativeSearchHost(p.apiBase) nativeSearch = nativeSearch && isNativeSearchHost(p.apiBase)
if len(tools) > 0 || nativeSearch { if len(tools) > 0 || nativeSearch {
requestBody["tools"] = buildToolsList(tools, nativeSearch) requestBody["tools"] = buildToolsList(tools, nativeSearch)