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

3.7.0 fails reading 'addAttribute' of undefined #654

Open
tenjaa opened this issue Jun 6, 2024 · 2 comments
Open

3.7.0 fails reading 'addAttribute' of undefined #654

tenjaa opened this issue Jun 6, 2024 · 2 comments

Comments

@tenjaa
Copy link

tenjaa commented Jun 6, 2024

Since the update to 3.7.0 my lambda fails.

Here are the logs of it failing:

INIT_START Runtime Version: nodejs:18.v29	Runtime Version ARN: arn:aws:lambda:eu-west-1::runtime:e78f4a8a086bd7395a083454a3b1a85e8bb06f09428b715c8078dfc31ce0c35c
2024-06-06T10:01:18.236Z	undefined	ERROR	_X_AMZN_TRACE_ID is missing required information
2024-06-06T10:01:18.237Z	undefined	ERROR	Empty or non-string trace ID provided
2024-06-06T10:01:18.341Z	undefined	INFO	Found <XXX>. Setting up proxy.
START RequestId: <XXX> Version: 453
2024-06-06T10:01:18.469Z	<XXX>	ERROR	Invoke Error 	
{
    "errorType": "TypeError",
    "errorMessage": "Cannot read properties of undefined (reading 'addAttribute')",
    "stack": [
        "TypeError: Cannot read properties of undefined (reading 'addAttribute')",
        "    at file:///var/task/index.mjs:7438:18",
        "    at file:///var/task/index.mjs:16411:16",
        "    at file:///var/task/index.mjs:11253:14",
        "    at async file:///var/task/index.mjs:8931:26",
        "    at async Catalog.getCredentials (file:///var/task/index.mjs:36684:26)",
        "    at async Runtime.handler (file:///var/task/index.mjs:36631:7)"
    ]
}

END RequestId: <XXX>
REPORT RequestId: <XXX>	Duration: 114.86 ms	Billed Duration: 115 ms	Memory Size: 512 MB	Max Memory Used: 85 MB	Init Duration: 399.98 ms	
XRAY TraceId: 1-<XXX>	SegmentId: 0b2b67f75caf1811	Sampled: true	

This is how it looked right before the update:

INIT_START Runtime Version: nodejs:18.v29	Runtime Version ARN: arn:aws:lambda:eu-west-1::runtime:e78f4a8a086bd7395a083454a3b1a85e8bb06f09428b715c8078dfc31ce0c35c
2024-06-06T10:01:42.058Z	undefined	INFO	Found <XXX>. Setting up proxy.
START RequestId: <XXX> Version: 451
END RequestId: <XXX>
REPORT RequestId: <XXX>	Duration: 295.29 ms	Billed Duration: 296 ms	Memory Size: 512 MB	Max Memory Used: 93 MB	Init Duration: 414.31 ms	
XRAY TraceId: 1-<XXX>	SegmentId: 2f89a17922b0696d	Sampled: true	

The code consists of two files and gets built/deployed using the cdk node function.
catalog handler:

import {captureAWSv3Client} from 'aws-xray-sdk';
import {SecretsManagerClient} from '@aws-sdk/client-secrets-manager';
import {proxyHandler} from '../src/proxy.js';
import {load} from '../env.js';
import {Catalog} from './catalog.js';

const secretsManagerClient = captureAWSv3Client(new SecretsManagerClient({
  requestHandler: proxyHandler,
}));
export const handler = new Catalog(secretsManagerClient, load('SECRET_ARN')).handler;

catalog:

[...]
export class Catalog {
  private clientId?: string;

  constructor(private readonly secretsManagerClient: SecretsManagerClient, private readonly secretArn: string) {
  }

  public handler: APIGatewayProxyHandlerV2 = async () => {
    if (!this.clientId) {
      await this.getCredentials();
    }
[...]
  };

  private async getCredentials() {
    const command = new GetSecretValueCommand({
      SecretId: this.secretArn,
    });
    const secretOutput = await this.secretsManagerClient.send(command);
    this.clientId = JSON.parse(secretOutput.SecretString!).client_id;
  }
}
@karmaniverous
Copy link

Same. Only cost me a whole day's work. 🙄

@wangzlei
Copy link
Contributor

wangzlei commented Jun 6, 2024

The PR introduced the issue has been reverted by #657
Please bump to the latest 3.8.0 with the fix.

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

No branches or pull requests

3 participants