amazon-archives / aws-apigateway-importer

Tools to work with Amazon API Gateway, Swagger, and RAML
Apache License 2.0
518 stars 140 forks source link

BadRequestException with Conflicting Paths #72

Closed yushun closed 9 years ago

yushun commented 9 years ago

I'm getting the following error when I'm trying to push to AWS. I think it is conflicting against the root path "/"

Creating resource '{crossdomain}' on vsm9rb12bc
2015-10-28 11:28:02,414 ERROR - Error importing API definition
com.amazonaws.services.apigateway.model.BadRequestException: Resource with id 'ghyqqo' has a       conflicting path (Service: null; Status Code: 400; Error Code: null; Request ID: 7a2e58aa-7d88-11e5-    b028-fb290b0e528f)
    at com.amazonaws.http.AmazonHttpClient.handleErrorResponse(AmazonHttpClient.java:1219)
    at com.amazonaws.http.AmazonHttpClient.executeOneRequest(AmazonHttpClient.java:803)
    at com.amazonaws.http.AmazonHttpClient.executeHelper(AmazonHttpClient.java:505)
    at com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:317)
    at com.amazonaws.hal.client.HalClient.invoke(HalClient.java:235)
    at com.amazonaws.hal.client.HalClient.postResource(HalClient.java:98)

Here is the json. This is needed for Unity3D, so I cannot nest the path.

    "/{crossdomain}": {
        "get": {
            "summary": "For WebPlayer, get crossdomain xml",
            "description": "called by the webpalyer",
            "parameters": [
                {
                    "name": "crossdomain",
                    "in": "path",
                    "description": "will always be crossdomain xml",
                    "required": true,
                    "type": "string"
                }
            ],
            "responses": {
                "200": {
                    "description": "everything is ok"
                }
            },
            "x-amazon-apigateway-auth": {
                "type": "none"
            },
            "x-amazon-apigateway-integration": {
                "type": "http",
                "uri": "https://shadowhealth-devmodules.s3.amazonaws.com/crossdomain.xml",
                "httpMethod": "GET",
                "responses": {
                    "2\\d{2}": {
                        "statusCode": "200"
                    }
                }
            }
        }
    }
rpgreen commented 9 years ago

I've just tested with "/" and "/{x}" and there were no validation errors.

If you have "/", "/x", and "/{y}" this will be in conflict and is not supported by the service at this time. Please reopen if you're still having issues

bigbadtrumpet commented 9 years ago

Do you have any suggestion on how to get around the reason we need to do this?

Due to their security the Unity3D WebPlayer makes a crossdomain.xml get call to the root of the url before allowing the main call to execute. for example if a call is made to a.com/b/c/d unity will call a.com/crossdomain.xml. Anyway possible for API gateway to work with a.com/b/c/d and a.com/crossdomain.xml?

rpgreen commented 9 years ago

We are aware of this general issue and hope to have a proper solution in the near future.

I don't think theres a good workaround for now besides defining every path part as a parameter (i.e. not static paths at all), and implementing logic in mapping template or in lambda functions depending on the value of the path parameter. i.e. if param == "crossdomain.xml" respond with crossdomain.xml, else...

akotranza commented 9 years ago

Interesting that this specific case can be fixed easily by allowing all valid url encoded characters in the resource path... '.' is a valid character!

I sure can fire up an API in ExpressJS in about 2 seconds and route a /crossdomain.xml endpoint to serve whatever I need. And every other web framework worth its salt... AWS :(

AaronRustad commented 9 years ago

Do you know if this was something that was just enforced in the service? I swear this had been working for me up until a day or two ago.

My paths that are now complaining are:

/videos/search
/videos/{id}
bigbadtrumpet commented 9 years ago

yea it appears to be something that changed recently because we have apis that exist that have this in use already that still work but can't have any new resources added to it.

cfair commented 9 years ago

+1 for me on encountering this recently. Using a swagger file I created a gateway with a few weeks ago, it now fails with this validation reason.

EDIT: found this forum posting: https://forums.aws.amazon.com/thread.jspa?threadID=218106&tstart=0 This is now intended behavior.

rpgreen commented 9 years ago

There was a service change last week to resolve a bug - previously the behavior when calling an API with multiple "conflicting" resource paths was not well-defined or documented.

We are aware that this is affecting users and are working on an improved solution, expected next week. With this fix, resource paths such as defined in this issue will be allowed. At runtime, static paths will take precedence over parameterized paths.

Thanks for your patience.

AaronRustad commented 9 years ago

That's excellent news! Thanks for the update @rpgreen .

pcutz commented 9 years ago

Hello @rpgreen can you confirm if this change will be rolled out this week? I am hoping to provide a status update on the api we're building by the end of the week, and this is blocking a few things.

Would like to know if I should implement some workarounds, or wait for this to be completed.

Thanks, Patrick

rpgreen commented 9 years ago

Rolling out as we speak. This should be available in all regions by EOD.

AaronRustad commented 9 years ago

Is there a place where we can see "release notes", "feature releases", "big fixes" for AAG? I appreciate you letting us know the status of this, but it seems like AAG should be announcing when these things are delivered.

Also: Can you confirm that this particular issue was rolled out? ;-)

rpgreen commented 9 years ago

This was deployed yesterday - please let me know if you're still experiencing issues

AaronRustad commented 9 years ago

I can confirm that this works again. Thanks!

akotranza commented 9 years ago

We've also been able to successfully deploy again using both the aws console and the swagger importer, as well as remove workarounds for getting it to work w/ Unity3d clients. Thanks for listening @rpgreen !