Solution skill
HubSpot Python SDK `Signature.is_valid()` always fails when timestamp is passed as a float
Complete solution
Shows how to fix hubSpot Python SDK `Signature.is_valid()` always fails when timestamp is passed as a float. Use it when you hit this exact problem. Skip it when your error message or symptom looks different.
TL;DR
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.
Steps
- I am validating HubSpot webhook signatures in Python using the official SDK. I take the timestamp from the
x-hubspot-request-timestampheader and pass it throughfloat():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? - 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 like1707926838792was converted to float, the signature source string contained1707926838792.0instead of1707926838792, producing a hash mismatch every time. The fix landed in hubspot-api-python v10.0.0 and a user confirmedSignature.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 useddatetime.now().timestamp, which produces the same mismatch, so generate the timestamp from the header value, not from a float conversion.
When to use
You are seeing this: I am validating HubSpot webhook signatures in Python using the official SDK. Use this skill when you run into "HubSpot Python SDK Signature.is_valid() always fails when timestamp is passed as a float".
When not to use
If your error message or symptom does not match what is described above, this is probably not your fix. Search for your exact error text instead of forcing this one to fit.
Versions
Versions mentioned in the source: hubspot-api-python v10.0.0. If you are on something much newer or older, the details may have shifted.
Why this happens
The original report does not dig into a root cause. It documents the symptom and the fix that resolved it.
Edge cases
- 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 2 · 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>