Are you sure you are setting the metafield on the discount you are creating? The one associated with your function id? Your metafield is null on your input json as well, so I suspect you are not properly saving the metafield on the discount. You can query the discounts on your shop w/ GraphiQL to confirm.