Skip to content

Aggregates + RouteKeysConfig where the array of values does not work correctly #2248

@ArtyomZhuravlyov

Description

@ArtyomZhuravlyov

Expected Behavior / New Feature

My json

{
  "Routes": [
    {
      "DownstreamPathTemplate": "/comments",
      "DownstreamHostAndPorts": [
        {
          "Host": "localhost",
          "Port": 5002
        }
      ],
      "UpstreamPathTemplate": "/comments",
      "UpstreamHttpMethod": [
        "GET"
      ],
      "Key": "comments"
    },
    {
      "DownstreamPathTemplate": "/users/{id}",
      "DownstreamHostAndPorts": [
        {
          "Host": "localhost",
          "Port": 5001
        }
      ],
      "UpstreamPathTemplate": "/users/{id}",
      "UpstreamHttpMethod": [
        "GET"
      ],
      "Key": "user"
    }
  ],
  "Aggregates": [
    {
      "UpstreamPathTemplate": "/aggregatecommentuser",
      "RouteKeys": [
        "comments",
        "user"
      ],
      "RouteKeysConfig": [
        {
          "RouteKey": "user",
          "JsonPath": "$[*].userId",
          "Parameter": "id"
        }
      ]
    }
  ],
  "GlobalConfiguration": {
    "BaseUrl": "https://localhost:5003"
  }
}

I'm accessing the aggregating url: http://localhost:5003/aggregateСommentUser

The first request occurs for http://localhost:5002/comments
If my first query in the aggregation returns a response

"comments": [
        {
            "id": 1,
            "userId": 1
        },
        {
            "id": 2,
            "userId": 2
        }
    ],

Then when I request information about users, I should get a response.

      "user": [
        {
            "id": 1,
            "name": "Artem"
        },
        {
            "id": 2,
            "name": "Ivan"
        }
    ]

And the requests themselves should look like this:
1. http://localhost:5002/comments
2. http://localhost:5001/users/1
3. http://localhost:5001/users/2

Actual Behavior / Motivation for New Feature

I'm accessing the aggregating url: http://localhost:5003/aggregateСommentUser

The first request occurs for http://localhost:5002/comments
my first query in the aggregation returns a response

 "comments": [
        {
            "id": 1,
            "userId": 1
        },
        {
            "id": 2,
            "userId": 2
        }
    ],

I receive a response from the user service

      "user": [
        {
            "id": 1,
            "name": "Artem"
        },
        {
            "id": 1,
            "name": "Artem"
        }
    ]

Because my requests from Ocelot look like this:
1. http://localhost:5002/comments
2. http://localhost:5001/users/1
3. http://localhost:5001/users/1

Link to the repository: https://github.com/ArtyomZhuravlyov/OcelotAggregate

image
image

Specifications

  • Version: 23.4.2
  • Platform: .NET 8
  • Subsystem:

Metadata

Metadata

Assignees

Labels

AggregationOcelot feature: Request AggregationacceptedBug or feature would be accepted as a PR or is being worked onbugIdentified as a potential bugsmall effortLikely less than a day of development effort.

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions