Skip to content

fix(eks): truncate kubectl error output to avoid CloudFormation respo…#37384

Open
ashoknarayan wants to merge 3 commits intoaws:mainfrom
ashoknarayan:fix/kubectl-error-truncation
Open

fix(eks): truncate kubectl error output to avoid CloudFormation respo…#37384
ashoknarayan wants to merge 3 commits intoaws:mainfrom
ashoknarayan:fix/kubectl-error-truncation

Conversation

@ashoknarayan
Copy link
Copy Markdown

Fixes #37353

Problem

kubectl errors can exceed CloudFormation's 4KB response size limit, causing the actual error message to be lost and replaced with a generic "Response object is too long" message.

Solution

Truncate kubectl error output before raising exceptions to ensure it stays within safe limits.

Changes

  • Decode kubectl output safely using UTF-8 with fallback
  • Truncate error messages to 2048 characters
  • Append truncation indicator for clarity
  • Applied consistently across apply and patch handlers (aws-eks and aws-eks-v2)

Notes

This preserves useful error context while preventing CloudFormation response overflow.

@github-actions github-actions bot added bug This issue is a bug. p2 beginning-contributor [Pilot] contributed between 0-2 PRs to the CDK labels Mar 27, 2026
@aws-cdk-automation aws-cdk-automation requested a review from a team March 27, 2026 17:07
Copy link
Copy Markdown
Collaborator

@aws-cdk-automation aws-cdk-automation left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The pull request linter fails with the following errors:

❌ Fixes must contain a change to a test file.
❌ Fixes must contain a change to an integration test file and the resulting snapshot.

If you believe this pull request should receive an exemption, please comment and provide a justification. A comment requesting an exemption should contain the text Exemption Request. Additionally, if clarification is needed, add Clarification Request to a comment.

✅ A exemption request has been requested. Please wait for a maintainer's review.

@ashoknarayan
Copy link
Copy Markdown
Author

Exemption Request

This change modifies error handling in the kubectl Lambda handler by truncating error messages to stay within CloudFormation response size limits.

There is no change to synthesized infrastructure or observable template output, and the behavior is only triggered during runtime error scenarios. As such, adding integration tests or snapshot updates would not provide meaningful coverage.

Please let me know if you would still prefer a specific test approach.

@aws-cdk-automation aws-cdk-automation added the pr-linter/exemption-requested The contributor has requested an exemption to the PR Linter feedback. label Mar 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

beginning-contributor [Pilot] contributed between 0-2 PRs to the CDK bug This issue is a bug. p2 pr-linter/exemption-requested The contributor has requested an exemption to the PR Linter feedback.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

(@aws-cdk/aws-eks-v2-alpha): kubectl handler masks error messages with "Response object is too long" when kubectl output exceeds 4KB

2 participants