Skip to content

fix: handle nested FormData length keys - #11328

Closed
bellussi1 wants to merge 1 commit into
axios:v1.xfrom
bellussi1:fix/formdata-length-key
Closed

bellussi1 wants to merge 1 commit into
axios:v1.xfrom
bellussi1:fix/formdata-length-key

Conversation

@bellussi1

@bellussi1 bellussi1 commented Oct 15, 2026 •

Copy link
Copy Markdown

Summary

Fix formDataToJSON throwing when a nested FormData field is named length. The parser converts an intermediate array to an object before descending into a named child, treating the key as data while preserving indexed siblings and repeated values.

Linked issue

Closes #11295

Changes

  • Normalize intermediate arrays before traversing non-numeric child keys.
  • Add regression coverage for bracket and dot notation, deeper values, repeated values, and numeric siblings.
  • Add the required unreleased bug-fix note.

Validation

Environment: Node.js 24.13.0, npm 11.6.2.

  • npm ci --ignore-scripts — passed; npm reported 10 dependency audit findings (1 moderate, 9 high). No dependency changes are included.
  • npm run lint — passed.
  • npx eslint tests/unit/helpers/formDataToJSON.test.js — passed.
  • npm run build — passed.
  • Focused parser tests — passed (20 tests).
  • Related indexed-field and request-consistency tests — passed (30 tests).
  • Full unit suite — 1,668 passed, 1 failed. The unrelated failure in tests/unit/adapters/fetch.test.js also reproduces on the clean base: expected Bearer VALID_USER_TOKEN, received Bearer CHANGED.
  • Browser headless suite — could not start because Chromium is missing; Playwright's browser download timed out three times.
  • GitHub Actions checked Oct 15, 2026 — four workflow runs (Continuous integration, Bundle Size, Verify build reproducibility, and zizmor) require maintainer approval; 17 required statuses are waiting to be reported. The two Socket checks completed (Project Report succeeded; Pull Request Alerts skipped), and AI/Greptile review runs were still in progress.

Compatibility and documentation

Patch-level bug fix. No public API, type, or compatibility changes. PRE_RELEASE_DOCS.md and type declarations are not needed for this internal parser correction. No packaging-specific checks apply.

Checklist

  • Scope, target branch v1.x, and linked issue checked
  • PRE_RELEASE_CHANGELOG.md entry added
  • Regression tests fail before and pass after the fix; numeric sibling behavior is covered
  • All applicable local checks completed (full unit suite has the unrelated base failure above; browser suite is blocked by the unavailable Chromium download)
  • Deferred release docs and ESM/CJS types are not needed
  • Semver impact stated; no breaking changes
  • Final diff reviewed for security, unrelated changes, generated artifacts, and test/debug leftovers
  • Latest GitHub Actions status recorded separately from review runs

AI-assisted contribution: the GitHub integration cannot apply the required ai-assisted label to an upstream pull request. A maintainer needs to apply it.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No issues found across 3 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

View guided diff | Re-trigger cubic

@greptile-apps

greptile-apps Bot commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] No blocking issues were identified. The narrowly scoped parser correction appears safe to merge.

Summary

Fixes nested FormData fields named length by converting intermediate arrays to objects before writing named children.

  • Nested FormData fields named length are stored as data.

No actionable issues were found, and no previous review threads were supplied. The code and tests were inspected; no tests were run for this review.

Reviews (2) · Last reviewed commit: "fix: handle nested FormData length keys" · Reviewed by Greptile

@bellussi1 bellussi1 closed this Oct 15, 2026
@bellussi1 bellussi1 reopened this Oct 15, 2026
@bellussi1
bellussi1 marked this pull request as ready for review October 15, 2026 22:56
@jasonsaayman jasonsaayman added ai-assisted This PR was created with or in conjunction with AI commit::fix The PR is related to a bugfix v1x Version 1 labels Oct 21, 2026

@jasonsaayman jasonsaayman left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

PR #11328 - fix: handle nested FormData length keys

Repo: axios/axios Author: @bellussi1 Base: v1.x Files: 3 **+47/-0
CI: Unavailable: no checks returned; no build/test workflow result is present in this snapshot. Mergeability: conflicting. Reviewed head: 7842a1effd5b38edff7c2e7bcd327990faaa48c5.

Repo Profile

Axios is an npm JavaScript HTTP client for browsers and Node, with XHR/Fetch/HTTP adapters, default and named exports, interceptors, headers/errors, and paired ESM/CJS declarations. The target uses Vitest plus browser and package/module tests; v1 packaging covers older Node CJS runtimes as well as current ESM, Bun and Deno. Contributions preserve transport/security boundaries, add regression coverage and prerelease records, and defer unreleased user docs to PRE_RELEASE_DOCS.md. This review uses the actual target-branch guidance and files, not the separate local v0 checkout.

Verdict

Close — A superior proposal covers the same defect without this candidate's drawbacks; see the comparison and scoped closure below.

Change Explanation And User Impact

This prevents a FormData path named length from mutating an intermediate array's special length slot by converting arrays to objects before descending through any nonnumeric segment. Executed metadata[length]=long plus metadata[0]=first: it fixes the target's RangeError and preserves both values. #11296 addresses the same failure with a narrower length-specific conversion and covers both insertion orders and the browser form entry point. The wider conversion here is not needed to solve the demonstrated length defect.

Validation scope: source/diff and regression-test review. Examples explicitly marked executed used isolated source snapshots on Node 24.18.0 with the workspace dependency installation; these were focused checks, not a clean install, full CI matrix, or full test-suite run. Author-reported test results were not treated as independently executed.

Competing PRs

Search: axios/axios open PRs, including drafts; full open-list scan plus formDataToJSON in:title,body, 11295 in:title,body, credential redaction in:title,body. Complementary searches were run across related APIs/issues; no query reached the 100-result cap and no search failed. The five explicitly excluded PRs were not reviewed or modified in this batch.

#11296 and #11328 address the same length-slot failure. #11296 uses a narrower guard and has both insertion orders plus browser HTML-form coverage, so it is preferred. #11278 preserves empty field names; #11280 supplies a benchmark; #11299 strengthens hardening tests. Those are complementary. Newly opened #11353 uses the same targeted guard as #11296, with fewer regressions and no prerelease entry; its combined length/nested/dotted cases are covered by #11296.

Preferred PR: #11296 retains the targeted guard with both insertion orders, repetition and browser HTML-form coverage.

Unique contributions: Preserve attribution for the independent reproductions in #11328 and #11353. No required unique coverage from either candidate is missing in #11296.

Action: Select #11328 and #11353 for scoped closure in favor of #11296 after final refresh; the retained candidate still requires validation. No closure is claimed here.

Project Fit

North star: Reliable HTTP transport and configuration across supported JavaScript environments, without embedding application-specific policy.

Benefits: Fixes length-named form fields; the retained candidate does so with narrower scope.

Tradeoffs: Converting for every named segment changes more traversal behavior than the targeted competing fix.

Fit: Strong — The underlying problem belongs in the transport, serializer, declarations or their maintenance tests.

Adversarial Review

Strongest objection: Converting for every named segment changes more traversal behavior than the targeted competing fix. Latest-head integration evidence is still needed.

Abuse/failure modes checked: Read both implementations and all added tests; compared the concrete failure and retained candidate coverage, including numeric-before-length and length-before-numeric paths.

Result: No concrete source defect established in the examined cases; validation and integration limits remain below.

Disposition

Close as duplicate/superseded
Selected for closure, not yet executed at the time of this review. Final closure is conditional on both heads remaining unchanged. Prepared explanation: “Thanks for the contribution. Consolidating this fix in #11296 because its narrower length guard covers both insertion orders and the browser form path. The replacement still needs its own validation before merge.”

Semver

patch — Corrects existing behavior or strengthens internal tooling/tests without adding a public API.

Breaking Changes

None intended beyond the bug correction described above; no public API removal or new runtime requirement is introduced by this diff.

Documentation

PRE_RELEASE_CHANGELOG.md records the change. No new API reference or migration is required for this scoped correction; keep the release description consistent with the behavior and limits above.

Performance And Regression Risk

Hot path touched: Yes — request/response processing or its shared helpers.

Performance concern: No unbounded new work identified in the changed path. Converting for every named segment changes more traversal behavior than the targeted competing fix.

Regression risk: low — the changed boundary needs regression and integration coverage, particularly after any rebase.

Evidence requested: The latest-head checks listed below; no extra benchmark requested for this scoped change.

Blocking Issues

  • Latest-head build/test validation is unavailable in the returned GitHub checks. Run or attach the repository build, relevant regression suite and required package/type/browser checks before merge; review/security bots alone do not establish that they pass. This is a validation hold, not an invented source defect.
  • GitHub reports merge conflicts with the current target. Resolve them and re-run relevant checks; the reviewed source snapshot is not a tested merge result.

Non-Blocking Suggestions

  • Retain attribution for this independent reproduction and approach in the consolidation discussion.

Looks Good

  • Read both implementations and all added tests; compared the concrete failure and retained candidate coverage, including numeric-before-length and length-before-numeric paths.

@jasonsaayman

Copy link
Copy Markdown
Member

Thanks @bellussi1 for the length-field reproduction and fix. I am consolidating this in #11296. It targets the special length slot without converting every nonnumeric path segment, and covers length-first/numeric-first ordering, repeated and nested fields, plus the browser HTML-form entry point. The required cases here are represented in that coverage. Closing this duplicate with credit for your independent contribution; #11296 still needs its own latest-head validation before merge.

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

Labels

ai-assisted This PR was created with or in conjunction with AI commit::fix The PR is related to a bugfix v1x Version 1

Projects

None yet

Development

Successfully merging this pull request may close these issues.

formToJSON throws for nested fields named length

2 participants