Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parsing fails due to "deleted" key not being present when implementing new library #47

Open
whittle opened this issue Jul 4, 2016 · 7 comments

Comments

@whittle
Copy link

whittle commented Jul 4, 2016

I’m writing an adapter library that uses stripe-core over http-conduit: https://github.com/whittle/stripe-http-conduit. It also leverages stripe-test as its test suite. I’m attempting to follow the example of stripe-http-streams as much as possible, but I’m getting a weird parse failure when I run the tests. Specifically, 77 of the test cases fail with the parse error key "deleted" not present. This struck me as particularly odd, as it seems to be originating from the call to Web.Stripe.Client.handleStream using the parser that is provided by StripeRequestF. The full output of the test run is available at http:https://lpaste.net/169059.

Do you have any insight on why this might be happening?

@dmjio
Copy link
Owner

dmjio commented Jul 5, 2016

Hey Jason, can you confirm the Stripe API version is being passed along in the HTTP header on the request.

Sent from my iPhone

On Jul 4, 2016, at 6:28 PM, Jason Whittle [email protected] wrote:

I’m writing an adapter library that uses stripe-core over http-conduit: https://github.com/whittle/stripe-http-conduit. It also leverages stripe-test as its test suite. I’m attempting to follow the example of stripe-http-streams as much as possible, but I’m getting a weird parse failure when I run the tests. Specifically, 80 of the test cases fail with the parse error key "deleted" not present. This struck me as particularly odd, as it seems to be originating from the call to Web.Stripe.Client.handleStream using the parser that is provided by StripeRequestF. The full output of the test run is available at http:https://lpaste.net/169059.

Do you have any insight on why this might be happening?


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or mute the thread.

@whittle
Copy link
Author

whittle commented Jul 5, 2016

Logging the request objects before I send them, the header that I’m setting is Stripe-Version: 2014-10-07. I’m using the V20141007 constructor from Web.Stripe.Client. The API version set in the dashboard is “2016-06-15 (latest)”. Additionally, when I look at the logs in the Stripe dashboard, that also shows the version as “2014-10-07”.

By the way, thank you for making such an excellent set of libraries. Its design and implementation are a credit to the Haskell community.

@dmjio
Copy link
Owner

dmjio commented Jul 7, 2016

@whittle, thank you, very kinds word of you.

So the version in the request should be overriding the version in your dashboard (this is true for all endpoints except historical data retrieval). As to why deleted wouldn't parse, that remains a mystery, the JSON instances from this library haven't changed. Unsure why a new http-client would cause a parse failure.

Can you paste some of the json that's being returned in the tests, specifically the objects where a parse failure exists.

@whittle
Copy link
Author

whittle commented Jul 7, 2016

As an example, here’s the result I get back from Stripe that causes an error in the test “Succesfully retrieves an Expanded Balance Transaction” (in response to a POST to /v1/customers/cus_8lFm4B1DHbhPc5):

Right (Object (fromList [("email",Null),("discount",Null),("livemode",Bool False),("default_card",String "card_18TjGZBfKr2Hg7NanRMY77CD"),("created",Number 1.467685587e9),("sources",Object (fromList [("has_more",Bool False),("data",Array [Object (fromList [("dynamic_last4",Null),("tokenization_method",Null),("country",String "US"),("fingerprint",String "dVh82fWtcOx2qDkS"),("address_zip_check",Null),("brand",String "Visa"),("address_city",Null),("address_state",Null),("funding",String "credit"),("customer",String "cus_8lFm4B1DHbhPc5"),("name",Null),("address_line1_check",Null),("cvc_check",String "pass"),("exp_month",Number 12.0),("address_zip",Null),("object",String "card"),("metadata",Object (fromList [])),("id",String "card_18TjGZBfKr2Hg7NanRMY77CD"),("exp_year",Number 2020.0),("address_line2",Null),("address_line1",Null),("last4",String "4242"),("address_country",Null)])]),("url",String "/v1/customers/cus_8lFm4B1DHbhPc5/sources"),("total_count",Number 1.0),("object",String "list")])),("currency",Null),("cards",Object (fromList [("has_more",Bool False),("data",Array [Object (fromList [("dynamic_last4",Null),("tokenization_method",Null),("country",String "US"),("fingerprint",String "dVh82fWtcOx2qDkS"),("address_zip_check",Null),("brand",String "Visa"),("address_city",Null),("address_state",Null),("funding",String "credit"),("customer",String "cus_8lFm4B1DHbhPc5"),("name",Null),("address_line1_check",Null),("cvc_check",String "pass"),("exp_month",Number 12.0),("address_zip",Null),("object",String "card"),("metadata",Object (fromList [])),("id",String "card_18TjGZBfKr2Hg7NanRMY77CD"),("exp_year",Number 2020.0),("address_line2",Null),("address_line1",Null),("last4",String "4242"),("address_country",Null)])]),("url",String "/v1/customers/cus_8lFm4B1DHbhPc5/cards"),("total_count",Number 1.0),("object",String "list")])),("shipping",Null),("object",String "customer"),("metadata",Object (fromList [])),("id",String "cus_8lFm4B1DHbhPc5"),("subscriptions",Object (fromList [("has_more",Bool False),("data",Array []),("url",String "/v1/customers/cus_8lFm4B1DHbhPc5/subscriptions"),("total_count",Number 0.0),("object",String "list")])),("account_balance",Number 0.0),("description",Null),("default_source",String "card_18TjGZBfKr2Hg7NanRMY77CD"),("delinquent",Bool False)]))

That’s the data structure after running the response body through Attoparsec using Data.Aeson.Parser.json as the parser.

@dmjio
Copy link
Owner

dmjio commented Jul 7, 2016

ah, which version of aeson are you using?

@dmjio
Copy link
Owner

dmjio commented Jul 7, 2016

stack exec ghc-pkg list | grep aeson

@whittle
Copy link
Author

whittle commented Jul 7, 2016

⇒ stack exec ghc-pkg list | grep aeson
aeson-0.11.2.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants