Skip to content

Commit 8b2706f

Browse files
committed
fix(oci): guard safety_mode.upper() against None value
Address Cursor Bugbot review: safety_mode is Optional, so the SDK can pass None when the user explicitly sets safety_mode=None. Guard with a None check before calling .upper() on both V1 and V2 paths.
1 parent 8f40152 commit 8b2706f

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

src/cohere/oci_client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -778,7 +778,7 @@ def transform_request_to_oci(
778778
chat_request["citationOptions"] = cohere_body["citation_options"]
779779
if "response_format" in cohere_body:
780780
chat_request["responseFormat"] = cohere_body["response_format"]
781-
if "safety_mode" in cohere_body:
781+
if "safety_mode" in cohere_body and cohere_body["safety_mode"] is not None:
782782
chat_request["safetyMode"] = cohere_body["safety_mode"].upper()
783783
if "logprobs" in cohere_body:
784784
chat_request["logprobs"] = cohere_body["logprobs"]
@@ -834,7 +834,7 @@ def transform_request_to_oci(
834834
chat_request["toolResults"] = cohere_body["tool_results"]
835835
if "response_format" in cohere_body:
836836
chat_request["responseFormat"] = cohere_body["response_format"]
837-
if "safety_mode" in cohere_body:
837+
if "safety_mode" in cohere_body and cohere_body["safety_mode"] is not None:
838838
chat_request["safetyMode"] = cohere_body["safety_mode"].upper()
839839
if "priority" in cohere_body:
840840
chat_request["priority"] = cohere_body["priority"]

0 commit comments

Comments
 (0)