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

Fix sending empty path for API resource /* when upstream has no base path #3632

Merged
merged 2 commits into from
Jan 7, 2025

Conversation

renuka-fernando
Copy link
Contributor

@renuka-fernando renuka-fernando commented Jan 6, 2025

Purpose

Issues

Fixes https://github.com/wso2-enterprise/choreo/issues/29592

Automation tests

  • Unit tests added: No
  • Integration tests added:No

Tested environments

Tested running Adapter only


Maintainers: Check before merge

  • Assigned 'Type' label
  • Assigned the project
  • Validated respective github issues
  • Assigned milestone to the github issue(s)

…path

Signed-off-by: Renuka Fernando <renukapiyumal@gmail.com>
var resourceRegex string
var substitutionString string
if resourcePath == "/*" && endpointBasepath == "" {
// If endpointBasepath is empty and resourcePath is "/*", enforce the path to be "/" to avoid setting empty path in upstream

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we support the case where we set a "/" (not /*) to the resources? eg (GET /, PUT / ..)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And also, if the client sends the "/" it should be forwarded to the backend ideally. If some backends needs the empty "/", then client can send it. Is this the way we support?

https://-dev-us-east-azure/dlif/request-info/v1.0/ -> https://bachendhost/context/
https://-dev-us-east-azure/dlif/request-info/v1.0 -> https://bachendhost/context

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we support the case where we set a "/" (not /*) to the resources? eg (GET /, PUT / ..)

Yes this is working, the only issue was with the "/*". Scenarios I've identified: https://github.com/wso2-enterprise/choreo/issues/29592#issuecomment-2572406585


And also, if the client sends the "/" it should be forwarded to the backend ideally. If some backends needs the empty "/", then client can send it. Is this the way we support?

https://-dev-us-east-azure/dlif/request-info/v1.0/ -> https://bachendhost/context/ https://-dev-us-east-azure/dlif/request-info/v1.0 -> https://bachendhost/context

When there is a context (working as expected when there is no context) in the upstream it always sends the trailing slash. i.e.

https://-dev-us-east-azure/dlif/request-info/v1.0 -> https://bachendhost/context/

This should be fixed too.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shall we fix this as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed and added unit tests

malinthaprasan
malinthaprasan previously approved these changes Jan 7, 2025
@malinthaprasan malinthaprasan dismissed their stale review January 7, 2025 03:18

Checking for one more fix

Signed-off-by: Renuka Fernando <renukapiyumal@gmail.com>
@renuka-fernando renuka-fernando merged commit 129d843 into wso2:choreo Jan 7, 2025
3 checks passed
@choreo-cicd
Copy link

[succeeded] Dataplane(NorthEU) cluster : dev-deployment-v2 : 20250107.18

@choreo-cicd
Copy link

[succeeded] Dataplane(EastUS) cluster : dev-deployment-v2 : 20250107.18

@choreo-cicd
Copy link

[succeeded] : dev-deployment-v2 : 20250107.18

@choreo-cicd
Copy link

[] Controlplane cluster : stage-deployment-v2 : 20250116.3

@choreo-cicd
Copy link

[] Dataplane(NorthEU) cluster : stage-deployment-v2 : 20250116.3

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

Successfully merging this pull request may close these issues.

5 participants