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

Encoding Problem while using Lambda #116

Closed
nactusem opened this issue Mar 23, 2016 · 21 comments
Closed

Encoding Problem while using Lambda #116

nactusem opened this issue Mar 23, 2016 · 21 comments
Labels
question General question

Comments

@nactusem
Copy link

I am using aws mobile sdk to save some data to dynamodb over lambda with Pojos. But before serialization process, json object and its attributes is normal as it should be

{ "address": { "S": "Ankara, Oğuzlar, 06520 Çankaya/Ankara, Türkiye" }, "creationDate": { "S": "Wed Mar 23 15:15:07 GMT+02:00 2016" }, "detail": { "S": "uç" }, "geohash": { "N": "1531222403039987611" }, "geoJson": { "S": "{\"type\":\"Point\",\"coordinates\":[32.8215751,39.901007]}" }, "jobHashKey": { "N": "153122" }, "kategori": { "S": "Tadilat" }, "photos": { "SS": [ "[\"file:///storage/emulated/0/WhatsApp/Media/WhatsApp%20Images/IMG-20160318-WA0000.jpg\"]" ] }, "place": { "M": { "lat": { "S": "32.8215751" }, "lng": { "S": "39.901007" } } }, "price": { "S": "255.0" } }

*After serialization it returns as below including corrupted Turkish characters.
*
{ "address": { "S": "Ankara, O��uzlar, 06520 ��ankaya/Ankara, T��rkiye" }, "creationDate": { "S": "Wed Mar 23 15:15:07 GMT+02:00 2016" }, "detail": { "S": "u��" }, "geohash": { "N": "1531222403039987611" }, "geoJson": { "S": "{\"type\":\"Point\",\"coordinates\":[32.8215751,39.901007]}" }, "jobHashKey": { "N": "153122" }, "kategori": { "S": "Tadilat" }, "photos": { "SS": [ "[\"file:///storage/emulated/0/WhatsApp/Media/WhatsApp%20Images/IMG-20160318-WA0000.jpg\"]" ] }, "place": { "M": { "lat": { "S": "32.8215751" }, "lng": { "S": "39.901007" } } }, "price": { "S": "255.0" }, "title": { "S": "��" } }

Couldnt find a solution for this, May I request your assistance, or is it a bug?
Thank you for your time.

@fosterzhang
Copy link
Contributor

@felusdomesticus Thanks for reporting. I am looking into this.

@fosterzhang
Copy link
Contributor

Are you using the latest version v2.2.13? A few internalization issues were addressed in v2.2.13.

@fosterzhang fosterzhang added the question General question label Mar 23, 2016
@nactusem
Copy link
Author

Yes, I am using that version, I addressed another bug fixed in that version #96

@fosterzhang
Copy link
Contributor

Would you please try this in Lambda console? I suspect Lambda doesn't return correct content.

@nactusem
Copy link
Author

I tried this in console and works perfect.

@fosterzhang
Copy link
Contributor

How to reproduce it? I have a simple echo function set up in Lambda. I set default locale to Turkish. I can see the correct content.

Lambda function

console.log('Loading event');

exports.handler = function(event, context) {
    console.log("Received event");
    console.log(event);
    context.done(null, event);
};

Java interface

public interface MyInterface {
    @LambdaFunction
    NameInfo echo(NameInfo nameInfo);
}

public class NameInfo {
    public String firstName;
    public String lastName;
    public NameInfo(String firstName, String lastName) {
        this.firstName = firstName;
        this.lastName = lastName;
    }
}

    Locale.setDefault(new Locale("tr", "TR"));
    NameInfo nameInfo = new NameInfo("Big", "Oğuzlar");
    NameInfo result = myInterface.echo(nameInfo);
    System.out.println(result.lastName);

@nactusem
Copy link
Author

I tried this case and with node js backend i can see the correct content. But with java backend lambda logs and android side content is wrong. On the other hand if i try with lambda console content is right. Here is my sample code.

Lambda function

public NameInfo javaEncodingTest(NameInfo nameInfo, Context context){ context.getLogger().log(nameInfo.toString()); return nameInfo; }

Java interface with Android

`
public interface MyInterface {
@lambdafunction
NameInfo javaEncodingTest(NameInfo nameInfo);
}

public class NameInfo {
public String firstName;
public String lastName;

public String getFirstName() {
return firstName;
}

public void setFirstName(String firstName) {
    this.firstName = firstName;
}

public String getLastName() {
    return lastName;
}

public void setLastName(String lastName) {
    this.lastName = lastName;
}

}

NameInfo nameInfo = new NameInfo();
nameInfo.setFirstName("türkçe");
nameInfo.setLastName("türkçe");
NameInfo result = myInterface.javaEncodingTest(nameInfo);
System.out.println(result.lastName);
`

Lambda console log is
START RequestId: da8ea4d1-f1c9-11e5-96ec-057690f11223 Version: $LATEST
t��rk��e t��rk��
END RequestId: da8ea4d1-f1c9-11e5-96ec-057690f11223
REPORT RequestId: da8ea4d1-f1c9-11e5-96ec-057690f11223 Duration: 0.73 ms Billed Duration: 100 ms Memory Size: 128 MB Max Memory Used: 37 MB

@fosterzhang
Copy link
Contributor

Hmm, interesting problem. I used Charles to sniff http traffic. I notice the SDK does sent correct content to Lambda. But for some reason, Lambda doesn't handle it correctly and return incorrect content. I'll loop Lambda team in for investigation.

@nactusem
Copy link
Author

Thank you for your response, how can I follow this issue? @fosterzhang

@nactusem
Copy link
Author

nactusem commented Apr 2, 2016

Is there any progress @fosterzhang ?

@fosterzhang
Copy link
Contributor

@felusdomesticus I know what's causing it, but I don't know why. I forwarded this issue to Lambda team.

@nactusem
Copy link
Author

Can you please change this to a bug? We are all awaiting this to continue properly our development and test @fosterzhang , thanks

@fosterzhang
Copy link
Contributor

@felusdomesticus Technically this isn't a bug in the SDK. I handed it over to Lambda team and they are working on it. Thank you for your patience.

@ngoclinh49
Copy link

hello, this issue are solve?

@fosterzhang
Copy link
Contributor

@ngoclinh49 This bug has been taken care of by the Lambda team. They will roll out the fix ASAP.

@fcabi
Copy link

fcabi commented Jun 1, 2016

@fosterzhang Is there any progress?
This makes lambda unusable. Please fix this ASAP.
Thanks.

@fosterzhang
Copy link
Contributor

@fcabi @ngoclinh49 This is beyond the SDK. I've pinged Lambda team to have it fixed ASAP.

@fosterzhang
Copy link
Contributor

@ngoclinh49 @fcabi @felusdomesticus FYI: this is fixed in a recent Lambda service update.

@saaksshi
Copy link

This issue again coming when I'm sending Arabic response in lambda

@saaksshi
Copy link

It's works fine in Lex console testing but in swift mobile app Arabic gets truncated.

@palpatim
Copy link
Member

@saaksshi Please open a new issue with complete details rather than extending a very old issue. The "Bug" template will have a list of information that will help developers troubleshoot the issue.

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

No branches or pull requests

6 participants