Repository navigation
fix(E3697): measure Lambda environment size as compact JSON bytes - #4860
Conversation
|
Hi team, on this fix(E3697) PR: the [CI] Test PR workflow run on the current head is still parked waiting for a first-time-contributor approval (action_required). Could a maintainer approve the run so CI can proceed? Thanks. |
|
Hi @kddejong, friendly follow up: the CI runs on this PR are still parked at the first-time-contributor approval gate (action_required), so the checks cannot start until a maintainer approves the run. Could you approve it when you have a moment? Thanks! |
Lambda measures the environment variables map as compact JSON, so the structural characters (four quotes and a colon per variable, commas between variables, two braces) count toward the 4 KB limit. Summing key and value lengths undercounts by 6n + 1 bytes for n variables, letting oversized maps through. Measure the UTF-8 byte length of the compact JSON encoding instead. Fixes aws-cloudformation#4858 Signed-off-by: Varshith Puli <pulivarshit@gmail.com>
8583bcf to
e23ea93
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4860 +/- ##
=======================================
Coverage 94.69% 94.69%
=======================================
Files 442 442
Lines 16091 16092 +1
Branches 3121 3121
=======================================
+ Hits 15237 15238 +1
Misses 470 470
Partials 384 384
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Summary
E3697 summed the lengths of environment variable keys and values, but Lambda measures the variables map as compact JSON (
{"KEY":"value",...}). The structural characters (four quotes and a colon per variable, a comma between variables, two braces) add 6n + 1 bytes for n variables, so the rule undercounted: with 100 variables, 3,496 bytes of keys plus values is 4,097 bytes of JSON, which the rule treated as 600 bytes under the limit while Lambda rejects the deployment.This measures the UTF-8 byte length of the compact JSON encoding (
separators=(",", ":"),ensure_ascii=Falseso multi-byte characters count as UTF-8 bytes, consistent with #4841) instead of summing key/value lengths.Verification
E3697 Lambda environment variables total size (4101) exceeds the 4 KB (4096 bytes) limit); a map at exactly 4,096 JSON bytes stays silent.test_function_environment_size.pysuite (13 tests) and the wholelmbdrule directory (218 tests) pass. Ruff check and format clean.Note: this composes with the pending #4841 (intrinsic resolution and UTF-8 counting); I will rebase once that lands.
Fixes #4858