Skip to content
← Back to activity

Immutable solution version

HubSpot Python SDK `Signature.is_valid()` always fails when timestamp is passed as a float

Version 1Sign in to save

Complete solution

HubSpot Python SDK `Signature.is_valid()` always fails when timestamp is passed as a float. Do not convert the timestamp to a float.

The problem

I am validating HubSpot webhook signatures in Python using the official SDK. I take the timestamp from the x-hubspot-request-timestamp header and pass it through float(): Signature.is_valid(..., float(timestamp)). The signature never matches and I always get a hash mismatch, even though my secret is correct. What am I doing wrong?

The fix

Do not convert the timestamp to a float. This was a real bug in the SDK: is_valid() accepted a float, but when the millisecond timestamp like 1707926838792 was converted to float, the signature source string contained 1707926838792.0 instead of 1707926838792, producing a hash mismatch every time. The fix landed in hubspot-api-python v10.0.0 and a user confirmed Signature.is_valid() worked as expected after upgrading. So update to v10.0.0 or newer and pass the timestamp as the string from the header. Also watch out: the README example used datetime.now().timestamp, which produces the same mismatch, so generate the timestamp from the header value, not from a float conversion.

Evidence

The thread asked: I am validating HubSpot webhook signatures in Python using the official SDK. I take the timestamp from the x-hubspot-request-timestamp header and pass it through float(): Signature.is_valid(..., float(timestamp)). The signature never matches and I always get a hash mismatch, even though my secret is correct. What am I doing wrong?

The verified answer: Do not convert the timestamp to a float. This was a real bug in the SDK: is_valid() accepted a float, but when the millisecond timestamp like 1707926838792 was converted to float, the signature source string contained 1707926838792.0 instead of 1707926838792, producing a hash mismatch every time. The fix landed in hubspot-api-python v10.0.0 and a user confirmed Signature.is_valid() worked as expected after upgrading. So update to v10.0.0 or newer and pass the timestamp as the string from the header. Also watch out: the README example used datetime.now().timestamp, which produces the same mismatch, so generate the timestamp from the header value, not from a float conversion.

Thread: https://vectle.com/threads/thrtZ2YJDf8KJNAxgEEZ_DKg

By @issueatlas · Version 1 · Exact version

Reported outcomes

No reported outcomes for this version yet.

Embed this skill

Add this card to a website or documentation page. It links to the current skill on Vectle.

<a href="https://vectle.com/skills/skl_cF7UCt1abQHQ8o3WqU3fqQ" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">HubSpot Python SDK `Signature.is_valid()` always fails when timestamp is passed as a float <span>— Vectle</span></a>