Skip to content

fix(form): preserve nested length fields in JSON conversion - #11296

Open
dhairyajangir wants to merge 14 commits into
axios:v1.xfrom
dhairyajangir:fix/form-json-length-fields
Open

dhairyajangir wants to merge 14 commits into
axios:v1.xfrom
dhairyajangir:fix/form-json-length-fields

Conversation

@dhairyajangir

@dhairyajangir dhairyajangir commented Oct 6, 2026 •

Copy link
Copy Markdown

Summary

Preserve nested fields named length when converting FormData or an HTML form to JSON. The intermediate array currently assigns values such as metadata[length]=long to its special length slot, throwing RangeError or dropping data. Convert that container to an ordinary object before descending into the named slot.

Linked issue

Closes #11295.

Changes

  • Guard a length segment on an intermediate array.
  • Cover both insertion orders, deeper nesting, repeated fields, dotted keys and a real HTML form.
  • Retain the prerelease bug-fix entry and all upstream notes. Commit cd263dc3 resolves the changelog conflict with current v1.x at 4ee8d46f; the original implementation and regression-test blobs are unchanged.

Validation

Complete local checks on the exact published tree 0cff277cecb8c7a26a8283ee0a41625a1ba74bd0, Linux / Node26.10.0 / npm11.19.1, on12November:

  • npm ci --ignore-scripts, changelog Prettier check, Conventional Commit lint, npm run lint and npm run build: passed.
  • npm run test:vitest:unit: 1,787 passed, all77 files.
  • npm run test:vitest:browser:headless: 1,125 passed, three existing skips, all84 files across Chromium, Firefox and WebKit.
  • Both complete suites ran with the repository’s default tests/settings under a2GiB, no-swap, one-CPU resource limit. Existing extracted WebKit libraries supplied the host’s libavif dependency. No test, assertion, timeout, retry option or tracked source was changed during validation.
  • Existing exact-tree fork evidence reproduces all six added regressions on the clean target and passes them on this candidate: run43159055898. New complete local runs above resolve the earlier hosted-only validation gap; earlier interrupted/failing attempts remain recorded in the discussion.

The four new-head upstream workflows (continuous integration, bundle size, build reproducibility and zizmor) require maintainer authorization and have executed zero jobs. Automated review/security results are separate from those workflows and human approval. Current checks

Compatibility and documentation

Patch bug fix; no intentional breaking change or public API/type/export/package/build-configuration change. Ordinary numeric arrays remain arrays; only the reserved named array slot becomes an object. The prerelease entry records the behavior; no deferred API documentation or declaration change is needed. Prior packed CJS/ESM module/smoke results remain historical, without a new full runtime-matrix claim.

The independent reproductions in #11328 and #11353 are acknowledged; this PR retains the narrower guard, both insertion orders and HTML-form coverage.

Checklist

  • Scope, supported target branch and linked issue checked
  • Prerelease entry updated and retained once
  • Regression tests and negative/prototype guards preserved
  • Applicable local checks completed on the exact published tree
  • Docs/types applicability assessed above
  • Patch impact and compatibility stated
  • Final diff reviewed for unrelated changes, security and generated artifacts
  • Latest upstream CI status recorded separately from bot reviews

AI assisted with implementation, conflict resolution, validation, review and this description. The repository’s ai-assisted label is applied.

@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.

All reported issues were addressed

Reply to a comment to ask cubic a question or push back. It learns from your replies.

Re-trigger cubic

@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.

All reported issues were addressed across 4 files

Requires human review: Auto-approval blocked because this review re-detected 1 unresolved issue already reported by Cubic.

Re-trigger cubic

@greptile-apps

greptile-apps Bot commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no actionable issues were found.

Summary

Preserves nested fields named length when converting FormData or an HTML form to JSON.

  • FormData conversion keeps nested fields named length.

Reviews (9) · Last reviewed commit: "chore: sync form JSON fix with v1.x" · Reviewed by Greptile

@dhairyajangir
dhairyajangir marked this pull request as ready for review October 6, 2026 03:46
@dhairyajangir

Copy link
Copy Markdown
Author

The complete local validation now passes on unchanged head 286cde538075354cb04f7289cb4d2f473e846f6d (Node 26.10.0/npm 11.19.1):

  • npm run test:vitest:unit: 1,374 passed, zero failures.
  • npm run test:vitest:browser:headless: 804 passed, three existing skips, zero failures across Chromium, Firefox and WebKit.

These were single full attempts run sequentially, without source/configuration changes or test suppression. The description retains the earlier failures; this result does not establish their cause. Existing lint, build and regression checks also pass.

Marked ready for review now that the local validation blocker is resolved. Could a maintainer authorize the four pending Actions workflows and apply the required ai-assisted label? Upstream CI and maintainer review remain pending.

@jasonsaayman jasonsaayman added commit::fix The PR is related to a bugfix v1x Version 1 labels Oct 7, 2026
@dhairyajangir
dhairyajangir marked this pull request as draft October 8, 2026 08:22
@dhairyajangir

Copy link
Copy Markdown
Author

Merged v1.x at 1a94bdb into this branch, resolving only the prerelease changelog conflict. All upstream entries and this PR's existing entry are retained. The contribution's production and test files are byte-identical to the previous head; the complete merged tree was independently reviewed.

On Node 26.10.0/npm 11.19.1, clean installation, changelog formatting, lint, build and all 1,523 unit tests pass. The full browser run has 839 passes, three skips and one failure: Firefox's existing asynchronous-adapter test did not observe its mock XHR within the one-second wait. The same focused case passes on both unchanged upstream and the candidate in all three browsers. Those focused checks do not establish the cause or turn the failed full suite into a pass.

I am keeping this draft while the required browser-validation limitation remains. No tests, timeouts, workers or suppression settings were changed. This merge repair and its review were AI-assisted; please retain/apply ai-assisted. Upstream Actions and maintainer review remain separate requirements.

Verified published head: a62a813d543fe6ffd271d9fc0d54bb741f91010a. The changelog conflict is cleared; all four Actions workflows on this head currently await maintainer authorization.

@jasonsaayman
jasonsaayman marked this pull request as ready for review October 9, 2026 16:56
@dhairyajangir

Copy link
Copy Markdown
Author

Resolved the new changelog conflict in 3253ee82, merging v1.x at 43968f29. All upstream entries remain; the original PR source/tests are unchanged. Independent review and complete public-tree verification passed.

On Node 26.10.0, lint/build and the full suites pass: 1,670 unit tests; 1,041 browser tests with three existing skips. The PR description now records this evidence. Could a maintainer authorize the four current-head Actions workflows and apply ai-assisted?

@dhairyajangir

Copy link
Copy Markdown
Author

Resolved the new prerelease-changelog conflict in a5a9e3a2 by merging current v1.x (326843a3). All upstream entries are retained, this PR's entry occurs once, and the original source/tests are unchanged. Independent review and complete public-tree/parent verification passed.

On Linux / v26.10.0, install, formatting, lint and build passed. The full default unit suite passes 1706 tests, and the full browser suite passes 1068 tests with 3 existing skips across Chromium, Firefox and WebKit. Each suite ran once, without filters, retries or relaxed settings. Earlier failure causes remain unproven.

Current-head Actions awaiting maintainer authorization: Verify build reproducibility, Bundle Size, GitHub Actions Security Analysis with zizmor, Continuous integration. Other running or bot checks do not establish executed test success or human approval. The body records the new head and evidence. Please authorize CI when appropriate and apply the required ai-assisted label; AI assistance was used for the repair, tests and review.

@jasonsaayman jasonsaayman added the ai-assisted This PR was created with or in conjunction with AI label 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 #11296 - fix(form): preserve nested length fields in JSON conversion

Repo: axios/axios Author: @dhairyajangir Base: v1.x Files: 4 **+53/-0
CI: Unavailable: no checks returned; no build/test workflow result is present in this snapshot. Mergeability: mergeable. Reviewed head: a5a9e3a2cabcd4630f19b85dd7de401e15f33b93.

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

Request changes — No concrete source defect found in this review; the missing latest-head validation prevent merge approval.
Posted as a comment review for the validation/integration hold; no formal code-change request is implied beyond the specific items below.

Change Explanation And User Impact

An intermediate array used while reconstructing FormData has a special length property. A field such as metadata[length]=long can assign an invalid array length and throw before normalization. This fix converts the container to an ordinary object before descending into that reserved array slot. Executed metadata[length]=long followed by metadata[0]=first: the target threw RangeError; this head returned an object preserving both entries. It covers reversed insertion order, deeper paths, repeated fields and the browser HTML-form entry point while retaining normal numeric-array behavior.

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: Preserves length-named form fields without assigning to an array length slot.

Tradeoffs: The targeted conversion avoids broadening every named-key traversal solely to address length.

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

Adversarial Review

Strongest objection: The targeted conversion avoids broadening every named-key traversal solely to address length. Latest-head integration evidence is still needed.

Abuse/failure modes checked: Compared both length proposals, ran the failing input, and inspected numeric-first/length-first, nested, dotted, repeated and browser regressions.

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

Disposition

Continue
Address the specific blockers below; no unrelated scope or complementary PR should be closed.

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. The targeted conversion avoids broadening every named-key traversal solely to address length.

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.

Non-Blocking Suggestions

  • Keep both insertion-order regressions and the browser formToJSON case during consolidation with #11328.

Looks Good

  • Compared both length proposals, ran the failing input, and inspected numeric-first/length-first, nested, dotted, repeated and browser regressions.

@dhairyajangir

dhairyajangir commented Oct 31, 2026 •

Copy link
Copy Markdown
Author

Update 11 November: the published head is 95bd3f0fce8212237790ee761f3566c454bf4872, merging v1.x at 83426bc8. The changelog conflict is resolved; the helper and both regression files are unchanged from the previous PR head. All six Node regressions and the HTML-form case remain, including both insertion orders and deeper/repeated/dotted fields. The independent reproductions in #11328 and #11353 are acknowledged.

The current PR description records the exact-tree evidence: locked install, lint and build passed; 1,777 unit tests and 1,125 browser tests passed, with three skips, across Chromium, Firefox and WebKit. The packed CJS module/smoke suites passed 8/72 checks on Node 18.20.8, and the ESM suites passed 9/78 on Node 26.10.0. Earlier failed browser attempts, baseline comparisons and the final full rerun remain disclosed in the description; these are local results, not an upstream CI pass.

All four workflows for this head still show action_required: continuous integration, bundle size, build reproducibility and zizmor. The existing request for maintainer authorization and review remains pending. Bot results are separate from maintainer approval; no competing PR was changed or closed.

AI assisted with integration, validation, review and this update.

@dhairyajangir

dhairyajangir commented Nov 12, 2026 •

Copy link
Copy Markdown
Author

The PR currently conflicts with v1.x at 4ee8d46. I prepared a conflict-only merge locally: the prerelease changelog retains upstream entries and this PR’s entry; the contribution’s source and tests are unchanged. The candidate tree is 0cff277cecb8c7a26a8283ee0a41625a1ba74bd0; it has not been pushed to this PR. The target-relative patch includes the PR changes against that target.

On that exact tree, a fork-hosted run on Node 26.10.0/npm 11.19.1 passed npm ci --ignore-scripts, lint, build, 1,787 unit tests, and 1,125 headless browser tests across Chromium, Firefox and WebKit (three skipped). The six added Vitest cases passed on the candidate and failed when copied into the clean target tree. One unit test passed on its existing test-local retry; no retry option was added.

This is hosted fork validation, not upstream CI. The required current-target local install, lint, build, unit and browser checks for this candidate have not been run; a local browser attempt on the other Axios PR was stopped under memory pressure. Would you accept the hosted evidence for a conflict-only branch update, or should I wait until the full local checks can be completed? AI assisted with the investigation, validation and this comment.

Resolve the prerelease changelog conflict while retaining upstream notes
and the existing implementation and regression tests unchanged.

Local install, format, lint, build, 1787 unit tests and the full headless
browser suite (1125 passes, three existing skips) passed on tree0cff277c.

AI assisted conflict resolution, validation and review.
@dhairyajangir

Copy link
Copy Markdown
Author

Resolved the changelog conflict in cd263dc3, retaining all upstream notes and the original implementation/tests unchanged.

Complete local checks on this exact tree now pass: locked install, formatting, commit lint, source lint, build, 1,787 unit tests and 1,125 browser tests across all three engines (three existing skips). No test settings, assertions or retries were changed. The PR description records the commands and earlier limitations. GitHub reports the branch mergeable; four current-head workflows still need maintainer authorization.

AI assisted the integration and validation.

@dhairyajangir

dhairyajangir commented Nov 23, 2026 •

Copy link
Copy Markdown
Author

I tested the published head cd263dc3 on macOS arm64 with Node 20.20.2, 22.23.5 and 24.22.3. Lint and build passed on all three, and the focused form-to-JSON unit file passed all 21 tests on each. The focused form browser tests passed on Chromium and WebKit on all three. Firefox could not start its temporary profile on this machine. The full Node 24 unit run passed all 1,787 tests and the browser run completed 750 passes and two skips across Chromium and WebKit. The full Node 22 unit run had two adapter failures, and Node 20 had adapter failures followed by a Vitest reporter error. This verifies the form regressions across the requested matrix with the full-suite limits above. Codex ran and reviewed these checks.

The exact-head Linux fork run completed. Lint, build and the complete Chromium, Firefox and WebKit suite passed on each Node version (1,125 passed and three skipped per version). Node 24 also passed all 1,787 unit tests. Node 22 passed 1,786 unit tests with one failure in the fetch-adapter suite. Node 20 reported the same fetch-adapter failure and then a Vitest reporter error because Map.groupBy was unavailable. The affected adapter files and adapter test are outside the form-conversion diff.

I then synced the branch to v1.x at 60d72961 for the up-to-date merge rule. The original form helper and regression blobs are identical. On the new head 755507da, all 21 focused unit tests pass on Node 20, 22 and 24, and all 1,806 unit tests pass locally on Node 26.13.1. The current head also passed 1,134 browser tests with three skips on each of Nodes 20, 22 and 24 across Chromium, Firefox and WebKit. Node 24 passed all 1,806 Linux unit tests. Node 22 passed 1,805 unit tests with one fetch-adapter failure. Node 20 reported that same adapter failure before its Vitest reporter stopped at the missing Map.groupBy. The browser results come from the Node 22 run and the recovered Node 20/24 run. The other two lanes in the Node 22 run were canceled after Ubuntu package setup stalled and their replacement completed.

Could a maintainer authorize the current upstream CI workflow when convenient?

This branch has not been deployed

No deployments
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