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

aws-lambda: default values discrepancies between TypeScript and Web documentation #13908

Closed
Serede opened this issue Mar 31, 2021 · 4 comments · Fixed by #14562
Closed

aws-lambda: default values discrepancies between TypeScript and Web documentation #13908

Serede opened this issue Mar 31, 2021 · 4 comments · Fixed by #14562
Assignees
Labels
@aws-cdk/aws-lambda Related to AWS Lambda bug This issue is a bug. effort/small Small work item – less than a day of effort p2

Comments

@Serede
Copy link

Serede commented Mar 31, 2021

https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-lambda.EventSourceMappingOptions.html

There seems to be some inconsistencies in the default values specified for the EventSourceMappingOptions interface between TypeScript source and Web versions of the CDK package documentation.

At least, these are the ones that I found:

  • maxRecordAge
    • Source says @default Duration.days(7).
    • Web says default: infinite or until the record expires.
    • Empirical default value: -1 (infinite)
  • retryAttempts
    • Source says @default 10000.
    • Web says default: infinite or until the record expires.
    • Empirical default value: -1 (infinite)

Please make default values consistent between TypeScript and Web versions of the documentation as many of us rely on TypeScript LSP for documentation.


This is a 📕 documentation issue

@Serede Serede added documentation This is a problem with documentation. feature-request A feature should be added or improved. needs-triage This issue or PR still needs to be triaged. labels Mar 31, 2021
@github-actions github-actions bot added the @aws-cdk/aws-lambda Related to AWS Lambda label Mar 31, 2021
@nija-at
Copy link
Contributor

nija-at commented Apr 13, 2021

Hi @Serede -

You are comparing the wrong artifacts. The typescript source you linked is of StreamEventSourceProps and here is the documentation for it - https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-lambda-event-sources.StreamEventSourceProps.html.

@nija-at nija-at added the closing-soon This issue will automatically close in 4 days unless further comments are made. label Apr 13, 2021
@Serede
Copy link
Author

Serede commented Apr 13, 2021

@nija-at you are right, thank you for clarifying. I still believe there is an issue with the default values, though. Let me explain better.

I created a DynamoEventSource like this:

    const testrunsEventSource = new DynamoEventSource(testrunsTable, {
      batchSize: 100,
      onFailure: new SqsDlq(deadLetterQueue),
      startingPosition: StartingPosition.TRIM_HORIZON,
    });

I see the constructor for DynamoEventSource takes DynamoEventSourceProps as second argument, which is itself an extension of the StreamEventSourceProps you just linked. There, the default values for StreamEventSourceProps are:

  • maxRecordAge. Type: Duration (optional, default: Duration.days(7))
  • retryAttempts. Type: number (optional, default: 10000)

So far so good. However, when I deployed the stack to CloudFormation, both properties took value -1 (infinite).

I had to change the code like this to make them finite:

    const testrunsEventSource = new DynamoEventSource(testrunsTable, {
      batchSize: 100,
      onFailure: new SqsDlq(deadLetterQueue),
      startingPosition: StartingPosition.TRIM_HORIZON,
      maxRecordAge: Duration.minutes(10),
      retryAttempts: 10,
    });

I reported the issue because I believe this can cause unintended behavior to other users as it did for me.

@github-actions github-actions bot removed the closing-soon This issue will automatically close in 4 days unless further comments are made. label Apr 14, 2021
nija-at pushed a commit that referenced this issue May 6, 2021
…ypes

The defaults documented for `maxRecordAge` and `retryAttempts`
properties for event sources that are 'stream' type were documented
incorrectly.

The implementation falls back to the defaults provided by
CloudFormation.

fixes #13908
@nija-at
Copy link
Contributor

nija-at commented May 6, 2021

@Serede - You are indeed correct. The defaults documented are incorrect.

I have submitted a fix for this - #14562

@nija-at nija-at added bug This issue is a bug. effort/small Small work item – less than a day of effort p2 and removed documentation This is a problem with documentation. feature-request A feature should be added or improved. needs-triage This issue or PR still needs to be triaged. labels May 6, 2021
@mergify mergify bot closed this as completed in #14562 May 12, 2021
mergify bot pushed a commit that referenced this issue May 12, 2021
…ypes (#14562)

The defaults documented for `maxRecordAge` and `retryAttempts`
properties for event sources that are 'stream' type were documented
incorrectly.

The implementation falls back to the defaults provided by
CloudFormation.

fixes #13908


----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
@github-actions
Copy link

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

hollanddd pushed a commit to hollanddd/aws-cdk that referenced this issue Aug 26, 2021
…ypes (aws#14562)

The defaults documented for `maxRecordAge` and `retryAttempts`
properties for event sources that are 'stream' type were documented
incorrectly.

The implementation falls back to the defaults provided by
CloudFormation.

fixes aws#13908


----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-lambda Related to AWS Lambda bug This issue is a bug. effort/small Small work item – less than a day of effort p2
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants