cloudflare / Stout

A reliable static website deploy tool
MIT License
751 stars 29 forks source link

Accounts with CF distributions which have empty CustomErrorResponse.ResponseCode fields cause create errors #7

Open victorquinn opened 9 years ago

victorquinn commented 9 years ago

Screenshot: screen shot 2015-08-11 at 4 31 24 pm

I dug into it a bit, appears this error is coming from the goamz module Stout uses under the hood when it tries to fetch the Cloudfront information. It appears to be attempting to deserialize XML which isn't valid XML and it barfs.

Side note: Any reason Stout isn't using the official AWS Go library?

Will continue to investigate and update here as this makes Stout unusable for me, can't even create a site.

victorquinn commented 9 years ago

More details:

victorquinn commented 9 years ago

Ok bit more progress, definitely an XML decoding issue in the goamz module.

In addition to throwing the error on line 625 in cloudfront.go as I referenced in my last comment when the XML is being decoded (strconv.ParseInt: parsing "": invalid syntax), when I inspect the distributions it got from the decoder it only has the first distribution whereas I actually have 14 distributions returned in the XML.

Trying to figure out what about my Cloudfront distributions could have caused issues with it, we don't have anything unorthodox that I'm aware of.

I'd open an issue on the goamz module but that fork appears to be only used here...

zackbloom commented 9 years ago

Hey @victorquinn,

We don't use the official AWS Go library only because our use of goamz predates its release. Any chance you can post the XML it's trying to decode? In particular we are looking for something which is an int in the struct (like this, this or this) but is either blank or not included in the XML text.

victorquinn commented 9 years ago

Hi @zackbloom thanks for ringing in.

Don't feel comfortable posting it (as it includes some sensitive company information), but happy to send it to you directly for analysis. I'm looking myself and haven't been able to see anything out of the ordinary.

Everything in the structs which should be an int is an int in the XML that I can see. It's 1300 lines of XML so it's taking some time to go through every possibility.

victorquinn commented 9 years ago

With the addition of some println statements in the goamz module, isolated that it's throwing the error trying to decode the CustomErrorResponses chunk.

It appears that one of my Cloudfront distributions has CustomErrorResponse items with a blank ResponseCode tag whereas the goamz struct which corresponds to it expects that to be an int. See my attached screenshot:

screen shot 2015-08-12 at 10 45 19 am

victorquinn commented 9 years ago

Yup, confirmed, it was CustomErrorResponse.

I didn't actually need those so I went into Cloudfront and removed all of them and re-ran it and everything works perfectly now.

Should update the goamz fork to allow Cloudfront distributions with Custom Error Responses because I suspect not all organizations will be able to just delete them in order to get Stout to run.

renandincer commented 8 years ago

Should be fixed by https://github.com/EagerIO/Stout/commit/2822cca845e7032f25c3fbeb8f51265c395eca44 as it replaces the goamz/cloudfront package with the official AWS Go SDK.