Skip to content

feat!: enforce default fieldNestingDepth of 32 - #1433

Open
UlisesGascon wants to merge 1 commit into
v3from
feat/enforce-limits-defaults-h696
Open

feat!: enforce default fieldNestingDepth of 32#1433
UlisesGascon wants to merge 1 commit into
v3from
feat/enforce-limits-defaults-h696

Conversation

@UlisesGascon

Copy link
Copy Markdown
Member

The v3 constructor already enforces default values for fieldNameSize, fieldSize, fields, fileSize, files, and headerPairs. fieldNestingDepth was the last documented limit without an enforced default (gated by ?? Infinity in the constructor), leaving deeply-nested field names as the one unbounded per-field allocation path.

This adds a default of 32, matching the shape of the other limits:

  • Well above legitimate form usage (typically 3-5 levels of nesting).
  • Small enough to bound the per-bracket append-field allocation cost.
  • Applications that need more can opt in with limits.fieldNestingDepth.

The existing "should allow unlimited nesting by default" test is replaced with two tests: one asserting the default is enforced (33 brackets rejects), and one asserting explicit opt-in to a higher limit still works.

Breaking change for next major. Consumers relying on unbounded nesting must set limits.fieldNestingDepth explicitly.

The v3 constructor already enforces default values for fieldNameSize,
fieldSize, fields, fileSize, files, and headerPairs. fieldNestingDepth
was the last documented limit without an enforced default, gated by
`?? Infinity` in the constructor.

This adds a default of 32, matching the shape of the other limits.
The value is generous compared to legitimate form nesting (typically
3-5 levels) and small enough to bound the per-bracket allocation cost
in append-field.

BREAKING CHANGE: applications relying on unbounded field name nesting
must now set `limits.fieldNestingDepth` explicitly to a higher value.
@UlisesGascon UlisesGascon self-assigned this Jul 18, 2026
@UlisesGascon
UlisesGascon marked this pull request as draft July 18, 2026 14:10
@coveralls

coveralls commented Jul 18, 2026

Copy link
Copy Markdown

Coverage Status

coverage: 100.0%. remained the same — feat/enforce-limits-defaults-h696 into v3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants