Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions adapters/stripe-style/scripts/lib.star
Original file line number Diff line number Diff line change
Expand Up @@ -178,10 +178,20 @@ def _coupon_public(doc):
# _bad_body reports a malformed JSON body authoritatively: undecodable bodies
# arrive as EMPTY DICTS via req.body, so the raw bytes are the only reliable
# signal (json_safe_decode returns None on malformed). Empty body = not bad.
# Form-encoded bodies (real SDK clients POST urlencoded, not JSON) are parsed
# by the engine into req.body — they are never "bad JSON".
def _bad_body(req):
raw = req.get("raw_body", "")
if raw == None or raw == "":
return False
h = req.get("headers")
ct = ""
if h != None:
ct = h.get("Content-Type", "")
if ct == None:
ct = ""
if ct.find("x-www-form-urlencoded") >= 0:
return False
return json_safe_decode(raw) == None

# _created_filters maps Stripe's `created` / `created[gt|gte|lt|lte]` query
Expand Down
Loading