Skip to content

Commit 260a38a

Browse files
vvillait88claude
andcommitted
chore: warn when associate_wallet idempotency_key exceeds 200 chars
Parity with node-sdk. Server truncates at 200 chars; two distinct keys sharing the first 200 chars would silently dedup. Emit a logger.warning on the "agentscore" logger so this is visible in dev without changing behavior (still sends the full key; server truncates). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 9e11ea8 commit 260a38a

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

‎agentscore/client.py‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,19 @@
11
from __future__ import annotations
22

3+
import logging
34
from importlib.metadata import version as _pkg_version
45
from typing import TYPE_CHECKING, Any
56

67
import httpx
78

89
from agentscore.errors import AgentScoreError
910

11+
logger = logging.getLogger("agentscore")
12+
13+
# Server truncates idempotency_key at 200 chars; warn the caller past that so two
14+
# distinct payments that share the first 200 chars don't silently dedup.
15+
_IDEMPOTENCY_KEY_MAX = 200
16+
1017
if TYPE_CHECKING:
1118
from agentscore.types import (
1219
AssessResponse,
@@ -209,6 +216,11 @@ def associate_wallet(
209216
# Truthy check (not `is not None`) so empty strings don't ship a useless key — mirrors
210217
# node-sdk's behavior of only forwarding when the key actually has content.
211218
if idempotency_key:
219+
if len(idempotency_key) > _IDEMPOTENCY_KEY_MAX:
220+
logger.warning(
221+
"associate_wallet: idempotency_key longer than %d chars will be truncated server-side.",
222+
_IDEMPOTENCY_KEY_MAX,
223+
)
212224
body["idempotency_key"] = idempotency_key
213225
client = self._get_sync_client()
214226
response = client.post("/v1/credentials/wallets", json=body)
@@ -316,6 +328,11 @@ async def aassociate_wallet(
316328
# Truthy check (not `is not None`) so empty strings don't ship a useless key — mirrors
317329
# node-sdk's behavior of only forwarding when the key actually has content.
318330
if idempotency_key:
331+
if len(idempotency_key) > _IDEMPOTENCY_KEY_MAX:
332+
logger.warning(
333+
"aassociate_wallet: idempotency_key longer than %d chars will be truncated server-side.",
334+
_IDEMPOTENCY_KEY_MAX,
335+
)
319336
body["idempotency_key"] = idempotency_key
320337
client = self._get_async_client()
321338
response = await client.post("/v1/credentials/wallets", json=body)

0 commit comments

Comments
 (0)