refactor(helpers): extract duplicated setFormDataHeaders into a shared helper - #11062
Merged
jasonsaayman merged 1 commit intoJul 15, 2026
Merged
Conversation
QodeXcli
added a commit
to QodeXcli/QodeX
that referenced
this pull request
Jul 2, 2026
…/axios#11062) (#97) The near-dupe finding on axios (setFormDataHeaders duplicated across resolveConfig.js and adapters/http.js) was reviewed by hand, consolidated into lib/helpers/setFormDataHeaders.js (keeping the defensive variant), verified against axios's own suite (lint clean, all 89 form-data tests green, the 2 remaining failures reproduced identically on an unmodified checkout), and submitted upstream: axios/axios#11062. Also documents what we deliberately did NOT submit — the hono clusters are behaviorally distinct on inspection (crypto branching; intentional URL-encoding difference) and the zod family is arguably deliberate API symmetry. Detection said "similar"; judgment said "leave them" — the same mechanical-evidence / human-judgment split maintain runs on. Co-authored-by: Louise Lau <QodeXcli@users.noreply.github.com>
QodeXcli
added a commit
to QodeXcli/QodeX
that referenced
this pull request
Jul 2, 2026
…s + exports cheat-sheet (#103) Completes the export story — every maintain artifact can now leave the terminal in the format its audience consumes: - maintain-audit --pdf: the auditor-facing one-pager — verification status up top (chain INTACT/BROKEN, head match, signature VALID/INVALID/unsigned, overall PASS/FAIL), then the full run chain as a readable table (seq, date, scope, outcome, files, checks, PR link), and the offline-verify instruction at the foot. buildAuditPdfBlocks is PURE (takes the verdict from verifyAuditLog); composes with --sign. - pdf-lite: "Page N of M" footers on multi-page documents (one-pagers stay clean). - ADOPTION.md "Every export, one place": an audience→command→artifact table covering demo/ report/audit/history exports; notes all PDFs come from the dependency-free writer. (axios/axios#11062 still OPEN with no review comments — the "merged upstream" docs update waits for the actual merge, honestly.) Co-authored-by: Louise Lau <QodeXcli@users.noreply.github.com>
Ziiyodullayevv
left a comment
There was a problem hiding this comment.
Good refactoring. Extracting duplicated setFormDataHeaders into a shared helper reduces code duplication and improves maintainability.
resolveConfig and the HTTP adapter carried separate copies of the formDataHeaderPolicy logic. Move that axios-specific behavior into lib/core/setFormDataHeaders.js so both call sites share the same filtering without expanding the generic helpers layer. Keep the defensive handling for missing FormData headers, add Node HTTP regression coverage, and record the user-visible robustness fix in the pre-release changelog.
jasonsaayman
force-pushed
the
refactor/dedupe-set-form-data-headers
branch
from
July 15, 2026 14:13
c94a93f to
14c01a0
Compare
jasonsaayman
approved these changes
Jul 15, 2026
21 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
lib/helpers/resolveConfig.jsandlib/adapters/http.jseach carry their own copy ofsetFormDataHeaders(plus theFORM_DATA_CONTENT_HEADERSlist). The two copies are identical except that theresolveConfig.jsone guards against a missing headers object (formHeaders || {}).This PR moves the function to
lib/helpers/setFormDataHeaders.js(one helper per file, matching the rest oflib/helpers) and imports it from both call sites, keeping the defensive variant — so the http adapter now also tolerates a FormData implementation whosegetHeaders()returnsundefined.No other behavior change: both call sites already invoke it with the same
(headers, data.getHeaders(), formDataHeaderPolicy)shape.Testing
npm run lintcleanvitest run --project unit: 946 passed — including all 89 form-data-related tests that exercise both touched call paths. (The two failures on my machine —fetch failed error as an AxiosError with ERR_NETWORKand the DNSshould handle errorscase — fail identically on an unmodified checkout; they are environment/DNS-dependent, not related to this change.)Found with an automated near-duplicate-helper detector I'm building (QodeX); the consolidation itself was reviewed and applied by hand.
Summary by cubic
Centralized FormData header handling by extracting
setFormDataHeadersintolib/core/setFormDataHeaders.jsand using it in bothresolveConfigand the Node HTTP adapter. Behavior is unchanged; the adapter now also toleratesFormData#getHeaders()returningundefinedwhenformDataHeaderPolicy: 'content-only'.Description
lib/core/setFormDataHeaders.jsand imported it inlib/helpers/resolveConfig.jsandlib/adapters/http.js.content-onlypolicy behavior and the guard for missingformHeaders.corerather than expanding generic helpers.(headers, data.getHeaders(), formDataHeaderPolicy). Pre-release changelog notes the Node robustness fix.Docs
/docs/form-data.mdconfirming both environments honorformDataHeaderPolicyand tolerate missing form-data headers.Testing
undefinedgetHeaders()results withcontent-onlypolicy.Semantic version impact
Written for commit 14c01a0. Summary will update on new commits.