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

[HTTP] Dispatching fails when same path param identifiers exist in a different order #342

Closed
chamil321 opened this issue Mar 21, 2020 · 0 comments · Fixed by ballerina-platform/module-ballerina-http#461
Assignees
Labels
module/http Priority/High Team/PCM Protocol connector packages related issues Type/Bug

Comments

@chamil321
Copy link
Contributor

Description:
$Subject

Steps to reproduce:

import ballerina/http;

@http:ServiceConfig { basePath: "/transform" }
service transformationService on new http:Listener(9090) {

    @http:ResourceConfig {
        path:"/{aaa}/go/{bbb}"
    }
    resource function twoPathParams(http:Caller caller, http:Request req, string aaa, string bbb) {
        http:Response res = new;
        json responseJson = {xxx:aaa, yyy:bbb};
        res.setJsonPayload(<@untainted json> responseJson);
        checkpanic caller->respond(res);
    }

    @http:ResourceConfig {
        path:"{bbb}/go/{aaa}/{ccc}"
    }
    resource function threePathParams(http:Caller caller, http:Request req, string aaa, string bbb, string ccc) {
        http:Response res = new;
        json responseJson = {aaa:bbb, bbb:aaa, ccc:ccc};
        res.setJsonPayload(<@untainted json> responseJson);
        checkpanic caller->respond(res);
    }
}

Request 1

curl -v localhost:9090/transform/chamil/go/elle/gamage
*   Trying 127.0.0.1...
* TCP_NODELAY set
* Connected to localhost (127.0.0.1) port 9090 (#0)
> GET /transform/chamil/go/elle/gamage HTTP/1.1
> Host: localhost:9090
> User-Agent: curl/7.64.1
> Accept: */*
> 
< HTTP/1.1 404 Not Found
< content-type: text/plain
< content-length: 85
< server: ballerina
< date: Sat, 21 Mar 2020 18:19:08 +0530
< 
* Connection #0 to host localhost left intact
no matching resource found for path : /transform/chamil/go/elle/gamage

Request 2

 curl -v localhost:9090/transform/chamil/go/elle/gamage
*   Trying 127.0.0.1...
* TCP_NODELAY set
* Connected to localhost (127.0.0.1) port 9090 (#0)
> GET /transform/chamil/go/elle/gamage HTTP/1.1
> Host: localhost:9090
> User-Agent: curl/7.64.1
> Accept: */*
> 
< HTTP/1.1 404 Not Found
< content-type: text/plain
< content-length: 85
< server: ballerina
< date: Sat, 21 Mar 2020 18:19:04 +0530
< 
* Connection #0 to host localhost left intact
no matching resource found for path : /transform/chamil/go/elle/gamage , method : GET* Closing connection 0

Observation

If path changes as follows, it works fine
resource 1 - path:"/{aaa}/go/{bbb}"
resource 2 - path:"{aaa}/go/{bbb}/{ccc}"

HttpResourceArguments collects all path param values against the identifier. If the same identifier occurs again, then the value is getting replaced.

This condition skips getting the same param getting replaced, but that condition is incorrect.

Affected Versions:
v1.2.0

@chamil321 chamil321 changed the title Dispatching fails when same path param identifiers exist in a different order [HTTP][Dispatching] Dispatching fails when same path param identifiers exist in a different order Mar 23, 2020
@chamil321 chamil321 changed the title [HTTP][Dispatching] Dispatching fails when same path param identifiers exist in a different order [HTTP] Dispatching fails when same path param identifiers exist in a different order Mar 23, 2020
@shafreenAnfar shafreenAnfar transferred this issue from ballerina-platform/ballerina-lang Oct 26, 2020
@anupama-pathirage anupama-pathirage added the Team/PCM Protocol connector packages related issues label Mar 1, 2021
@chamil321 chamil321 added this to the Swan Lake Beta2 milestone Jun 14, 2021
@chamil321 chamil321 self-assigned this Jun 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
module/http Priority/High Team/PCM Protocol connector packages related issues Type/Bug
Projects
None yet
3 participants