Skip to content

Commit 92fff7e

Browse files
chore(client): minor internal fixes
1 parent 249e51a commit 92fff7e

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/finch/_base_client.py

+10-1
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,8 @@ def _build_headers(self, options: FinalRequestOptions, *, retries_taken: int = 0
410410

411411
idempotency_header = self._idempotency_header
412412
if idempotency_header and options.method.lower() != "get" and idempotency_header not in headers:
413-
headers[idempotency_header] = options.idempotency_key or self._idempotency_key()
413+
options.idempotency_key = options.idempotency_key or self._idempotency_key()
414+
headers[idempotency_header] = options.idempotency_key
414415

415416
# Don't set these headers if they were already set or removed by the caller. We check
416417
# `custom_headers`, which can contain `Omit()`, instead of `headers` to account for the removal case.
@@ -944,6 +945,10 @@ def _request(
944945
request = self._build_request(options, retries_taken=retries_taken)
945946
self._prepare_request(request)
946947

948+
if options.idempotency_key:
949+
# ensure the idempotency key is reused between requests
950+
input_options.idempotency_key = options.idempotency_key
951+
947952
kwargs: HttpxSendArgs = {}
948953
if self.custom_auth is not None:
949954
kwargs["auth"] = self.custom_auth
@@ -1490,6 +1495,10 @@ async def _request(
14901495
request = self._build_request(options, retries_taken=retries_taken)
14911496
await self._prepare_request(request)
14921497

1498+
if options.idempotency_key:
1499+
# ensure the idempotency key is reused between requests
1500+
input_options.idempotency_key = options.idempotency_key
1501+
14931502
kwargs: HttpxSendArgs = {}
14941503
if self.custom_auth is not None:
14951504
kwargs["auth"] = self.custom_auth

0 commit comments

Comments
 (0)