question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ClientContext json exception when we have json input as payload

See original GitHub issue

I have a json payload of api gateway request for one of my java functions this is a seperate file http-event.json in my serverless stack

warmup:
    enabled: false
    cleanFolder: false
    memorySize: 256
    name:  ${self:custom.stageOption}-warmup
    timeout: 20
    prewarm: true
    payload: ${file(http-event.json)}

function produces payload with json string, but when invoking the function with client context below param is not working as it produces a JSON and when the target function gets invoked with the context it tries to json parse the string and getting an exception in target lambda

const params = {
      ClientContext: Buffer.from(`{"custom":${func.config.payload}}`).toString('base64'),
      FunctionName: func.name,
      InvocationType: "RequestResponse",
      LogType: "None",
      Qualifier: process.env.SERVERLESS_ALIAS || "$LATEST",
      Payload: func.config.payload
    };

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:11 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
jayasai470commented, Mar 26, 2020

@juanjoDiaz please suggest an approach by which we can use this plugin like having a flag to remove the clientContext or removing the clientContext completly? if so I can look into a PR ?

1reaction
jayasai470commented, Feb 7, 2020

so in that repo found this

/* Copyright 2015 Amazon.com, Inc. or its affiliates. All Rights Reserved. */

package com.amazonaws.services.lambda.runtime;

import java.util.Map;

/**
 * 
 * Provides information about client configuration and execution environment.
 *
 */
public interface ClientContext {
    /**
     * Gets the client information provided by the AWS Mobile SDK
     * 
     */
    public Client getClient();

    /**
     * Gets custom values set by the client application
     * <p>
     * This map is mutable (and not thread-safe if mutated)
     * </p>
     */
    public Map<String, String> getCustom();
 
    /**
     * Gets environment information provided by mobile SDK, immutable. 
     * 
     */
    public Map<String, String> getEnvironment();

}

custom is a map and does not support complex objects, not sure if its a requirement i couldn’t find any docs on this

Read more comments on GitHub >

github_iconTop Results From Across the Web

ClientContext json exception when we have json input as ...
I have a json payload of api gateway request for one of my java functions this is a seperate file http-event.json in my...
Read more >
ClientContext json exception when we have json input as payload -
I have a json payload of api gateway request for one of my java functions this is a seperate file http-event.json in my...
Read more >
Common JSON payload for cases and case types - IBM
The IBM® Case Manager REST protocol defines a JSON payload that is used in the methods that get or return information about a...
Read more >
lambda invoke payload error - Stack Overflow
The ClientContext JSON must be base64-encoded and has a maximum size of 3583 bytes. input := &lambda.InvokeInput{ // ClientContext: aws.
Read more >
Invoke - AWS Lambda - AWS Documentation
The request payload exceeded the Invoke request body JSON input quota. For more information, see Lambda quotas. HTTP Status Code: 413. ResourceConflictException.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found