Encoding issue when pulling data from table using AWS lambda

I'm trying to pull data from Honeycode table using AWS SDK command: queryTableRows. I'm doing this in Lambda. Rows that has correct encoding in Honeycode table (e.g. "Doliny Miętusiej") looses corect encoding once printed in Lambda as a string (e.g. "Doliny Miętusiej").
Any idea how can I assure same encoding in Honeycode table as in Lambda after queryTableRows command?

Regards
Andrzej

Hi @Andr-576d,

Thank you for getting in touch. I just wanted to let you know that I am talking to my engineering team about this. I will keep you updated on developments.

Hi @Andr-576d,

After a discussion with the engineering team, we may need further information.

  • I would like to confirm that you are using the AWS SDK with Lambda
  • What language are you using in lambda
  • We would appreciate it if you could share the code snippet where the issues are occurring. Remove any sensitive information from the code. I can reach out to you via email if necessary.

Dear Pankaj
thanks for your supprort. I'm using AWS Lambda Node.js 12.x. The lambda is deployed in eu-central-1 region. I'm developing in Cloud9 and runing function using "Run remote" (as opposite to "Run Local").

Below is my function code:

  
const AWS = require('aws-sdk');
const HC = new AWS.Honeycode({ region: 'us-west-2' });
const utf8 = require('utf8');

exports.handler = async (event, context, callback) => {
 
await extractFormattedTable(
      'my-table-id',
      'my-workbook-id',
      'my-condition'
    );
    
    callback();
};

async function extractFormattedTable(tableId, workbookId, filterFormula){
    var params = {
        tableId: tableId,
        workbookId: workbookId,
        filterFormula: {
            'formula': filterFormula
        }
    };
    
    try {
        var retData = await HC.queryTableRows(params).promise();
        console.log("RESULT: " + JSON.stringify(retData));
        
        retData.rows.forEach(function(row){
            row.cells.forEach(function(cell){
                console.log("------------------------");
                console.log("No encode: " + cell.formattedValue);
                
                console.log("------------------------");
                console.log("nodejs utf8 package: " + utf8.encode(cell.formattedValue));
            
                console.log("nodejs Buffer package: " + Buffer.from(cell.formattedValue, 'utf-8').toString());
                console.log("------------------------");
                
            });
        });
    } catch (e) {
        console.error("Error: " + e);
    }
}
  

As you see above, I've tested two options for encoding string. Build in Buffor package and utf8.js (utf8 - npm) but non of thoose options works for me.

Example output for one of returned records is:

  
2022-01-26 12:59:12.881 No encode: 172 | Bielsko Biała | Karpackie | Doliny Miętusiej 28
2022-01-26 12:59:12.881 ------------------------
2022-01-26 12:59:12.881 nodejs utf8 package: 172 | Bielsko Biała | Karpackie | Doliny Miętusiej 28
2022-01-26 12:59:12.881 nodejs Buffer package: 172 | Bielsko Biała | Karpackie | Doliny Miętusiej 28
  

while in honeycode table same cell looks like below:
image

Hi @Andr-576d,

Thank you for providing all the relevant information. The Eng team has run lambda directly from the lambda interface and found no issues.

Could you please test the lambda function directly from lambda interface to see if it works for you? If that is the case, we can rule out that the problem is not with the Lambda calling Honeycode, but with any other component in the flow.

Please keep us posted.

Hi Pankaj,
sorry for late response. As per your advice I've tested running from AWS console --> Lambda and it actually works:
image
When I did exactly the same from Cloud9 --> Run remote I got below:
image
So it looks there is something wrong with setting up Cloud9 to work with Honeycode (I also had issue that I was not able to run it locally).
Nevertheless, for me ability to run it from AWS console solves the issue. Many thanks for you and your team !

2 Likes

Hi @Andr-576d,

Glad to hear that workaround has unblocked you. Feel free to reach out to us if you have any further question.

Got an email today for AWS training - I shouldn't have.