Validate roleArn and durationSeconds before STS AssumeRole call by Copilot · Pull Request #156 · networknt/light-aws-lambda · GitHub
Skip to content

Validate roleArn and durationSeconds before STS AssumeRole call#156

Merged
stevehu merged 2 commits into
issue154from
copilot/sub-pr-155
Mar 20, 2026
Merged

Validate roleArn and durationSeconds before STS AssumeRole call#156
stevehu merged 2 commits into
issue154from
copilot/sub-pr-155

Conversation

Copilot AI commented Mar 20, 2026

Copy link
Copy Markdown
Contributor

When stsEnabled is true, missing or invalid roleArn/durationSeconds config values would silently propagate to the AWS SDK and produce opaque runtime exceptions. This adds early, explicit validation with clear error messages before any STS call is made.

Changes

  • assumeRole() pre-flight validation
    • Throws IllegalArgumentException if roleArn is empty/null
    • Throws IllegalArgumentException if durationSeconds is outside the AWS STS bounds (900–43200), including the invalid value in the message
    • Both checks are placed before the try-catch block so they surface as configuration errors, not wrapped RuntimeExceptions
// Validate roleArn is set when STS is enabled
if(StringUtils.isEmpty(config.getRoleArn())) {
    throw new IllegalArgumentException("roleArn must be configured when stsEnabled is true");
}
// Validate durationSeconds is within the allowed STS bounds (900–43200 seconds)
int durationSeconds = config.getDurationSeconds();
if(durationSeconds < 900 || durationSeconds > 43200) {
    throw new IllegalArgumentException("durationSeconds must be between 900 and 43200 (inclusive), but was: " + durationSeconds);
}

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Co-authored-by: stevehu <2042337+stevehu@users.noreply.github.com>

Copilot AI commented Mar 20, 2026

Copy link
Copy Markdown
Contributor Author

Copilot AI changed the title [WIP] [WIP] Address feedback on AWS STS support for lambda invoker in PR #154 Validate roleArn and durationSeconds before STS AssumeRole call Mar 20, 2026
Copilot AI requested a review from stevehu March 20, 2026 13:12
@stevehu stevehu marked this pull request as ready for review March 20, 2026 13:25
@stevehu stevehu merged commit 051fb06 into issue154 Mar 20, 2026
1 check passed
@stevehu stevehu deleted the copilot/sub-pr-155 branch March 20, 2026 13:25
stevehu added a commit that referenced this pull request Mar 20, 2026
* fixes #154 support AWS STS on the lambda invoker

* Update lambda-invoker/src/main/java/com/networknt/aws/lambda/LambdaFunctionHandler.java

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Update lambda-invoker/src/main/java/com/networknt/aws/lambda/LambdaFunctionHandler.java

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Update lambda-invoker/src/main/resources/config/lambda-invoker.yml

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Update lambda-invoker/src/main/resources/config/lambda-invoker.yaml

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Validate roleArn and durationSeconds before STS AssumeRole call (#156)

* Initial plan

* Add validation for roleArn and durationSeconds before STS AssumeRole

Co-authored-by: stevehu <2042337+stevehu@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: stevehu <2042337+stevehu@users.noreply.github.com>

* Add unit tests for STS-enabled code path in LambdaFunctionHandler (#157)

* Initial plan

* Add unit tests for STS code path in LambdaFunctionHandler

Co-authored-by: stevehu <2042337+stevehu@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: stevehu <2042337+stevehu@users.noreply.github.com>
Co-authored-by: Steve Hu <stevehu@gmail.com>

* Use StsAssumeRoleCredentialsProvider for automatic STS credential refresh (#158)

* Initial plan

* Replace StaticCredentialsProvider with StsAssumeRoleCredentialsProvider for automatic credential refresh

Co-authored-by: stevehu <2042337+stevehu@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: stevehu <2042337+stevehu@users.noreply.github.com>
Co-authored-by: Steve Hu <stevehu@gmail.com>

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com>
Co-authored-by: stevehu <2042337+stevehu@users.noreply.github.com>
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

Successfully merging this pull request may close these issues.

2 participants