Skip to content

Add safety margin to ECS container overrides length limit - #195

Merged
eiriksm merged 2 commits into
mainfrom
claude/trigger-length-trimming-tif38j
Sep 8, 2026
Merged

eiriksm merged 2 commits into
mainfrom
claude/trigger-length-trimming-tif38j

Conversation

@eiriksm

@eiriksm eiriksm commented Sep 8, 2026

Copy link
Copy Markdown
Member

Summary

Adjusted the ECS container overrides length limit to include a safety margin below AWS's hard limit of 8192 bytes, accounting for discrepancies between our serialization calculations and AWS's internal accounting.

Changes

  • Introduced overridesLengthSafetyMargin constant set to 64 bytes
  • Reduced overridesMaxLength from 8192 to 8128 bytes (8192 - 64)
  • Added explanatory comments documenting why the safety margin is necessary and how to adjust it if the gap changes

Details

AWS's ECS API has a hard limit of 8192 bytes for serialized container overrides, but their internal accounting can be stricter than our calculations. By applying a 64-byte safety margin, we reduce the risk of task submission failures due to length validation errors. This provides a buffer to account for any differences in how AWS measures the payload size versus our implementation.

https://claude.ai/code/session_013BnUutcaMNynydRnay6KPn

ECS rejects runTask when the serialized container overrides exceed
8192 characters, but real-world failures were happening even when our
own length check passed, since ECS's actual accounting doesn't match
ours exactly. Trim at 7500 instead so the oversized private_key env
var gets dropped earlier, leaving margin before the hard limit.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013BnUutcaMNynydRnay6KPn
7500 was too large a jump from the real 8192 limit. Express the trim
threshold as 8192 minus an adjustable overridesLengthSafetyMargin
const (64) instead, so it's easy to tune if the observed gap between
our length calculation and AWS's own accounting changes.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013BnUutcaMNynydRnay6KPn
@eiriksm
eiriksm enabled auto-merge (squash) September 8, 2026 06:39
@eiriksm
eiriksm merged commit 4624c8c into main Sep 8, 2026
4 checks passed
@eiriksm
eiriksm deleted the claude/trigger-length-trimming-tif38j branch September 8, 2026 06:40
@coveralls

Copy link
Copy Markdown

Coverage Status

coverage: 70.906% (+0.06%) from 70.849% — claude/trigger-length-trimming-tif38j into main

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.

3 participants