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

Using a semicolon in a value in QueryParameters suddenly doesn't work anymore #3955

Open
dcristolovean opened this issue Jan 28, 2025 · 9 comments
Labels
api Issues related to the API category bug Something isn't working pending-triage Issue is pending triage

Comments

@dcristolovean
Copy link

dcristolovean commented Jan 28, 2025

Describe the bug

I'm calling a REST API with some query parameters ([String : String]). The API call worked for months now. One value in the query is a string like "X;Y".
The server now receives only X and not the entire string.
I put this query dict in a RESTRequest that is simply passed to Amplify.API.get.

Any ideas what happened ? It might coincide with the update to 2.45.4 I did a few days ago.

PS: This suddenly became a huge issue, I realized I have values like this in 99% of the API calls. Having a ";" in any value in the query parameters, simply removes everything what's after the 1st semicolon.
I tried encoding it (%3B), not encoding it, nothing works. Amplify just kills it.

Steps To Reproduce

- Access any REST API call with Amplify that requires queryParameters and send a value with a semicolon somewhere in the middle.

Expected behavior

The server should receive the entire string, not only what's before the semicolon.

Amplify Framework Version

2.45.4

Amplify Categories

API

Dependency manager

Swift PM

@github-actions github-actions bot added pending-triage Issue is pending triage pending-maintainer-response Issue is pending response from an Amplify team member labels Jan 28, 2025
@harsh62
Copy link
Member

harsh62 commented Jan 28, 2025

@dcristolovean Thanks for opening the issue, I will work on reproducing this in my local environment and get back to you.

@harsh62 harsh62 added the api Issues related to the API category label Jan 28, 2025
@github-actions github-actions bot removed the pending-maintainer-response Issue is pending response from an Amplify team member label Jan 28, 2025
@dcristolovean
Copy link
Author

dcristolovean commented Jan 28, 2025

I did log the url with an interceptor and it seems the values are sent correctly (I think), as "x;y;z". Still the server now says it only gets "x".
From Android, my colleague encodes them (which I also tried) so he sends "x%3By%3Bz" which works on the server somehow. Android Amplify seems to leave them be and actually has this thing in the final URL.

The thing is I also tried to encode them, I can see the query parameters with %3B as soon as I pass them to Amplify, but the final url I see in the interceptor is still with ";"

So I would say double failure here :) . 1. Why does Amplify change my %3B to ";" in the final URL. 2. (this surely is not for you) Why does my AWS Rest API not understand "x;y" ?

Everything worked for weeks so far, just suddenly it doesn't work anymore.

@github-actions github-actions bot added the pending-maintainer-response Issue is pending response from an Amplify team member label Jan 28, 2025
@harsh62
Copy link
Member

harsh62 commented Jan 28, 2025

@dcristolovean What was the version you upgraded from?

@github-actions github-actions bot removed the pending-maintainer-response Issue is pending response from an Amplify team member label Jan 28, 2025
@dcristolovean
Copy link
Author

dcristolovean commented Jan 28, 2025

2.45.x ....something less than 4 :) I don't remember. 1, 2 or 3 :)
It's SPM and I deleted the Derived Data completely for other reasons, so it just downloaded the new version by itself.

@github-actions github-actions bot added the pending-maintainer-response Issue is pending response from an Amplify team member label Jan 28, 2025
@dcristolovean
Copy link
Author

dcristolovean commented Jan 28, 2025

Is it possible that a previous Amplify version was just encoding the ";" by itself ? That would explain why my server worked for me, even if I never encoded myself the ";" ?
And now the new version doesn't do that by default, as seen in the url i logged in the interceptor ? What's also different is that the Android Amplify does actually encode the ; in the final url.

@harsh62
Copy link
Member

harsh62 commented Jan 28, 2025

Yeah.. That could definitely be possible, I don't see anything that changed from 2.45.0 to 2.45.4 that should affect encoding. Are you able to test this in the following 3 versions by manually setting the version in SPM?

  • 244.0
  • 2.43.0
  • 2.42.0

And validate if you are seeing the same issue, atleast that would validate the hypothesis of something going wrong in one of the recent versions of Amplify Swift.

@github-actions github-actions bot removed the pending-maintainer-response Issue is pending response from an Amplify team member label Jan 28, 2025
@dcristolovean
Copy link
Author

This is getting even more interesting:

https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-known-issues.html
The semicolon character (;) is not supported for any request URL query string and results in the data being split.

Nice. But.. the problem is that now I can't send ";" encoded, as seen, Amplify removes my encoding.
Yes I will try to change the versions to see, not much else to do...

@github-actions github-actions bot added the pending-maintainer-response Issue is pending response from an Amplify team member label Jan 28, 2025
@harsh62 harsh62 removed the pending-maintainer-response Issue is pending response from an Amplify team member label Jan 28, 2025
@dcristolovean
Copy link
Author

dcristolovean commented Jan 28, 2025

OK, more info:

  1. 2.42.0 still logs my URL with ";" So no point in testing the newer ones

  2. THIS IS THE FIX, NOW IT WORKS:

class RESTInterceptor: URLRequestInterceptor {

func intercept(_ request: URLRequest) -> URLRequest {        
    var encodedRequest = request
    let urlString = (request.url?.absoluteString ?? "").replacingOccurrences(of: ";", with: "%3B")
    encodedRequest.url = URL(string: urlString)        
    return encodedRequest
}

}

Yes, this is the most horrific workaround you've ever seen, I know :). BUT IT WORKS. Considering I'm also hitting your AWS REST APIs, this is clearly a problem. It seems it never worked in Amplify, my bad. But it worked for years in AWSMobileClient, I was always sending "x;y;z" and the SDK was handling it correctly. And it works on Android, that SDK never replaces his encoding and leaves it as it is.

Let me know if you consider this an Amplify bug (which 100% it is :) ) and how to proceed from here.

@github-actions github-actions bot added the pending-maintainer-response Issue is pending response from an Amplify team member label Jan 28, 2025
@harsh62
Copy link
Member

harsh62 commented Jan 28, 2025

@dcristolovean Thanks for getting back and providing these details.. I'll keep this issue open as a bug, as Amplify Swift seems to be not doing encoding correctly whereas Android does.

I'll keep this at relatively lower priority since you have workaround and its not blocking you.

@github-actions github-actions bot removed the pending-maintainer-response Issue is pending response from an Amplify team member label Jan 28, 2025
@harsh62 harsh62 added the pending-maintainer-response Issue is pending response from an Amplify team member label Jan 28, 2025
@tylerjroach tylerjroach added the bug Something isn't working label Jan 28, 2025
@harsh62 harsh62 removed the pending-maintainer-response Issue is pending response from an Amplify team member label Jan 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api Issues related to the API category bug Something isn't working pending-triage Issue is pending triage
Projects
None yet
Development

No branches or pull requests

3 participants