Skip to content

docs: correct request config and AxiosHeaders descriptions - #11389

Merged
jasonsaayman merged 8 commits into
axios:v1.xfrom
yxshee:fix/docs-config-header-claims
Nov 9, 2026
Merged

jasonsaayman merged 8 commits into
axios:v1.xfrom
yxshee:fix/docs-config-header-claims

Conversation

@yxshee

@yxshee yxshee commented Oct 26, 2026

Copy link
Copy Markdown
Contributor

Summary

I found six statements in the README and the docs site that do not match what the code does on v1.x. I checked each one by running axios from the source tree with a small custom adapter, so no network was needed. This PR only changes documentation and adds a prerelease changelog entry.

Linked issue

None. This is a small docs-only correction, so I did not open an issue first. Happy to open one if you prefer.

Changes

  • transformRequest (README config block and request-config.md): the docs said it only applies to PUT, POST, PATCH and DELETE. dispatchRequest calls it for every request. A transformRequest passed to axios.get() is called.
  • transformRequest / transformResponse (request-config.md): the docs said each function gets the data "as its only argument". transformData calls fn(data, headers, status). A request transformer gets the data and an AxiosHeaders instance. A response transformer also gets the status code (200 in my test). This matches AxiosRequestTransformer and AxiosResponseTransformer in index.d.ts.
  • responseType (README config block): it was marked // default for 'json'. axios.defaults.responseType is undefined, and the two cases behave differently. With transitional.silentJSONParsing: false, an invalid JSON body throws ERR_BAD_RESPONSE when responseType: 'json' is set, but comes back as the raw string when responseType is left out. The transitional comment further down already says the option "defaults to no value", so the two parts of the README disagreed.
  • headers (request-config.md): the docs said Content-Type defaults to application/json. defaults.headers.common['Content-Type'] is undefined. A GET with no data sends no Content-Type. A POST with a string body gets application/x-www-form-urlencoded. Only a plain object gets application/json.
  • AxiosHeaders#get (header-methods.md): the docs said "The matcher is defaulted to true". With no second argument, get() returns the raw string (multipart/form-data; boundary=Asrf456BGe4h). Passing true returns the parsed object. The examples on the same page already show this.
  • AxiosHeaders#normalize (README and header-methods.md): the docs said axios calls it "after calling each interceptor". Interceptors do not normalize headers. transformData normalizes before each transformer. In my test, an interceptor that left both foo and Foo set passed both keys to the next interceptor. The transformRequest function then saw only foo.

Validation

  • Node v22, from the repo root after npm ci --ignore-scripts.
  • I ran scripts that import ./index.js and send requests through a custom adapter that echoes the config. Results on v1.x before this change:
    • transformRequest on axios.get(): called, 3 arguments, second is AxiosHeaders.
    • transformResponse: 3 arguments, second is AxiosHeaders, third is 200.
    • axios.defaults.responseType: undefined. Invalid JSON with silentJSONParsing: false returned "not json" without responseType and threw ERR_BAD_RESPONSE with responseType: 'json'.
    • Content-Type: GET with no data undefined, POST string application/x-www-form-urlencoded, POST object application/json, PUT URLSearchParams application/x-www-form-urlencoded;charset=utf-8. axios.defaults.headers.common['Content-Type'] is undefined.
    • headers.get('Content-Type') returned the raw string, and headers.get('Content-Type', true) returned the parsed object.
    • Keys seen by the next request interceptor: ['Accept', 'foo', 'Foo']. Keys seen by transformRequest: ['Accept', 'foo'].
  • npx prettier --check on the touched files reports the same warnings for README.md and request-config.md as it does on v1.x. My lines add no new formatting differences.
  • npx commitlint passes on the commit message.
  • Runtime checks (npm run lint, npm run build, unit and browser tests) do not apply. No code, types or tests changed.

Compatibility and documentation

Docs only. No semver impact, and no runtime, index.d.ts or index.d.cts changes. PRE_RELEASE_DOCS.md is not needed because this describes current behavior. I only updated the English pages. The es, fr and zh translations may have the same sentences, and I can update them here if you want.

This change was drafted with AI assistance and reviewed before submission; please add the ai-assisted label if a maintainer can.

Checklist

  • Scope, target branch, and linked issue/rationale checked
  • PRE_RELEASE_CHANGELOG.md entry added or updated (or AGENTS.md's automated release-preparation exception explained)
  • Regression tests and relevant negative/platform cases covered (or N/A with reason): N/A, docs only
  • Applicable local checks completed, with actual commands and results recorded above
  • Deferred release docs and ESM/CJS types/tests updated where needed (or N/A with reason): N/A, no API change
  • Semver impact stated and intentional breaking changes explained
  • Final diff reviewed for security, unrelated changes, generated artifacts, and test/debug leftovers
  • Latest GitHub Actions status recorded separately from review/security bot results

Several statements in the README and the docs site did not match what
the code does on v1.x:

- transformRequest runs for every request method, not only PUT, POST,
  PATCH and DELETE.
- Transform functions receive the headers (and, for responses, the
  status code), not the data as their only argument.
- responseType has no default value; it is not 'json'.
- There is no default Content-Type; axios picks one from the data.
- AxiosHeaders#get() without a matcher returns the raw value; true is
  not the default matcher.
- AxiosHeaders#normalize() runs before each transformer, not after each
  interceptor.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01NQDmA3mwGfL83pbg9WQ6ey
@yxshee
yxshee requested a review from jasonsaayman as a code owner October 26, 2026 12:15
@greptile-apps

greptile-apps Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Low impact] The documentation-only changes appear safe to merge.

Summary

Corrects request-config and header documentation in the README and the English, Spanish, French, and Chinese guides. No runtime or type changes.

  • Request and response transforms have clearer rules for when they run and what they receive.
  • The README marks responseType as unset by default.
  • Request config docs explain how Axios chooses Content-Type.
  • AxiosHeaders#get() docs explain raw values and optional parsing.
  • Header docs place normalization around transforms, not interceptors.

The previous documentation findings are addressed. No new issues found.

Reviews (8) · Last reviewed commit: "docs: limit the get() TypeError note to ..." · Reviewed by Greptile

Comment thread docs/pages/advanced/request-config.md Resolved
…der-claims

# Conflicts:
#	PRE_RELEASE_CHANGELOG.md
When no Content-Type is set and the request transforms do not pick one,
dispatchRequest sets application/x-www-form-urlencoded for post, put and
patch requests (lib/core/dispatchRequest.js). Mention that fallback next
to the data-based defaults so a plain string body is not assumed to go
out without a Content-Type.
Comment thread PRE_RELEASE_CHANGELOG.md Resolved
@jasonsaayman jasonsaayman added commit::docs The PR is related to docs v1x Version 1 labels Nov 9, 2026
# Conflicts:
#	PRE_RELEASE_CHANGELOG.md
Apply the same corrections to the Spanish, French, and Chinese request
config and header method pages: transformRequest runs for every method,
transformers receive the headers (and the status code for responses),
there is no static Content-Type default, AxiosHeaders#get() returns the
raw value without a matcher, and normalize() runs around the
transformers rather than after each interceptor.

Also tighten the English wording: say there is no static Content-Type
default instead of contradicting the post/put/patch fallback, use the
exact URLSearchParams content type, and note that normalize() runs once
more after the transformers. Update the prerelease entry to match.
@jasonsaayman jasonsaayman added the ai-assisted This PR was created with or in conjunction with AI label Nov 9, 2026

@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 10 files

Reply with feedback, questions, or to request a fix.

View guided diff | Re-trigger cubic

Comment thread docs/pages/advanced/request-config.md Resolved
Comment thread docs/pages/advanced/header-methods.md Resolved
- AxiosHeaders#get() takes an optional parser (true, a RegExp, or a
  function); any other value throws a TypeError. Describe it as a parser
  rather than a matcher in every language.
- axios derives Content-Type from data only for the types the default
  request transform handles; binary and stream bodies are left alone.
- The last transformRequest function may also return a Blob or File,
  which the default transform passes through and the adapters accept.
Comment thread docs/pages/advanced/header-methods.md Resolved
@jasonsaayman
jasonsaayman merged commit 98156ee into axios:v1.x Nov 9, 2026
markharding pushed a commit to futo-org/Harbor that referenced this pull request Nov 17, 2026
This PR contains the following updates:

| Package | Change | [Age](https://docs.renovatebot.com/merge-confidence/) | [Confidence](https://docs.renovatebot.com/merge-confidence/) |
|---|---|---|---|
| [axios](https://axios-http.com) ([source](https://github.com/axios/axios)) | [`1.21.0` → `1.21.1`](https://renovatebot.com/diffs/npm/axios/1.21.0/1.21.1) | ![age](https://developer.mend.io/api/mc/badges/age/npm/axios/1.21.1?slim=true) | ![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/axios/1.21.0/1.21.1?slim=true) |

---

> ⚠️ **Warning**
>
> Some dependencies could not be looked up. Check the [Dependency Dashboard](issues/2097) for more information.

---

### Release Notes

<details>
<summary>axios/axios (axios)</summary>

### [`v1.21.1`](https://github.com/axios/axios/releases/tag/v1.21.1)

[Compare Source](axios/axios@v1.21.0...v1.21.1)

#### v1.21.1 — November 9, 2026

This release raises the minimum `follow-redirects` version to fix a published CVE, fixes a Next.js prerendering failure caused by the response duration timer, corrects the `getAdapter` typings, and includes documentation corrections, new test coverage, CI runner changes and dependency updates.

#### 🔒 Security Fixes

- **follow-redirects:** Raised the `follow-redirects` range from `^1.16.0` to `^1.16.2` to fix CVE-2026-116689 (GHSA-mrwp-f3q8-3g9p). In the vulnerable versions, `sensitiveHeaders` arrays from another realm were ignored and custom credentials could follow redirects. Only the Node.js HTTP adapter is affected, and there are no API changes. (**[#&#8203;11410](axios/axios#11410)

#### 🐛 Bug Fixes

- **Response Duration:** `dispatchRequest` now measures `response.duration` with `performance.now()` and uses `Date.now()` only when `performance.now()` isn't available. In v1.21.0, any axios request from a Server Component failed Next.js production builds with Cache Components (`cacheComponents: true`), because Next.js rejects `Date.now()` while prerendering. The duration is still a whole number of milliseconds, and system clock changes no longer affect it. (**[#&#8203;11411](axios/axios#11411)
- **TypeScript:** `getAdapter` now accepts an optional `config?: AxiosRequestConfig` in `index.d.ts` and `index.d.cts`, matching what it does at runtime. You can now call `getAdapter('fetch', { env: { fetch: myFetch } })` without a cast. (**[#&#8203;11404](axios/axios#11404)

#### 🔧 Maintenance & Chores

- **Documentation Corrections:** Brought the README and docs site in line with how axios actually behaves:

  - `transformRequest` runs for every method, and transformers receive `(data, headers, status)`.
  - `responseType` and `Content-Type` have no default value.
  - `AxiosHeaders#get` and `#normalize` are described correctly.
  - Errors should be identified with `axios.isAxiosError()`, not by `name`.
  - The error tables now list `ECONNREFUSED` and `ERR_FORM_DATA_DEPTH_EXCEEDED`, and note that FormData parsing has a fixed depth limit that `maxDepth` doesn't change.
  - New notes cover what `redact` doesn't scan, which adapters enforce `maxContentLength` / `maxBodyLength`, and how `formToJSON()` handles field name collisions.

  (**[#&#8203;11374](axios/axios#11374, **[#&#8203;11373](axios/axios#11373, **[#&#8203;11389](axios/axios#11389, **[#&#8203;11419](axios/axios#11419, **[#&#8203;11429](axios/axios#11429, **[#&#8203;11430](axios/axios#11430)
- **Docs Site:** Added a Partners page, a shared card design for sponsors and partners, a Namespace sponsor badge, and a blog whose first post announces HeroDevs Never-Ending Support for Axios v0. Also applied the v1.20.0/v1.21.0 release notes to the docs, and fixed internal links in the es, fr and zh translations so they keep their locale prefix. (**[#&#8203;11390](axios/axios#11390, **[#&#8203;11399](axios/axios#11399, **[#&#8203;11400](axios/axios#11400, **[#&#8203;11412](axios/axios#11412, **[#&#8203;11401](axios/axios#11401)
- **Test Coverage:** Added cancellation tests across the HTTP, fetch and XHR adapters. They cover `AbortSignal`, `CancelToken`, cancelling while a request interceptor is pending, and timeout precedence. Also added tests for `no_proxy` edge cases in `shouldBypassProxy`, such as internationalized domain names, malformed CIDR and IPv4 entries, and port-qualified entries. Neither changes runtime behavior. (**[#&#8203;11376](axios/axios#11376, **[#&#8203;11431](axios/axios#11431)
- **CI:** GitHub Actions jobs now run on Namespace runners. The npm publish job stays on GitHub-hosted runners, because npm provenance and trusted publishing (OIDC) only work there. (**[#&#8203;11396](axios/axios#11396)
- **Dependencies:** Updated development and tooling dependencies, including `vitest` and `@vitest/*` (to 5.x at the root), `typescript` (7.x at the root), `vite`, `rollup`, `eslint`, `playwright`, `@commitlint/*`, `@rollup/plugin-alias`, `@rollup/plugin-terser`, `body-parser`, `multer`, `serialize-javascript`, `fast-uri`, `qs`, `zizmorcore/zizmor-action`, and `follow-redirects` in `/docs`. (**[#&#8203;11383](axios/axios#11383, **[#&#8203;11375](axios/axios#11375, **[#&#8203;11372](axios/axios#11372, **[#&#8203;11345](axios/axios#11345, **[#&#8203;11392](axios/axios#11392, **[#&#8203;11387](axios/axios#11387, **[#&#8203;11386](axios/axios#11386, **[#&#8203;11385](axios/axios#11385, **[#&#8203;11391](axios/axios#11391, **[#&#8203;11388](axios/axios#11388, **[#&#8203;11395](axios/axios#11395, **[#&#8203;11421](axios/axios#11421, **[#&#8203;11422](axios/axios#11422, **[#&#8203;11426](axios/axios#11426)
- **Release:** Prepared the 1.21.1 release. (**[#&#8203;11435](axios/axios#11435)

#### 🌟 New Contributors

We are thrilled to welcome our new contributors. Thank you for helping improve axios:

- **[@&#8203;Ghoscro](https://github.com/Ghoscro)** (**[#&#8203;11374](axios/axios#11374)
- **[@&#8203;pei711](https://github.com/pei711)** (**[#&#8203;11373](axios/axios#11373)
- **[@&#8203;ivanhapaz](https://github.com/ivanhapaz)** (**[#&#8203;11399](axios/axios#11399)
- **[@&#8203;aelmanaa](https://github.com/aelmanaa)** (**[#&#8203;11404](axios/axios#11404)
- **[@&#8203;Aryapatel-007](https://github.com/Aryapatel-007)** (**[#&#8203;11429](axios/axios#11429, **[#&#8203;11430](axios/axios#11430)
- **[@&#8203;umair-ghafoor-ai](https://github.com/umair-ghafoor-ai)** (**[#&#8203;11376](axios/axios#11376)
- **[@&#8203;yxshee](https://github.com/yxshee)** (**[#&#8203;11389](axios/axios#11389)
- **[@&#8203;malinele](https://github.com/malinele)** (**[#&#8203;11401](axios/axios#11401)
- **[@&#8203;AnantDuhan](https://github.com/AnantDuhan)** (**[#&#8203;11431](axios/axios#11431)

[Full Changelog](axios/axios@v1.21.0...v1.21.1)

</details>

---

### Configuration

📅 **Schedule**: (UTC)

- Branch creation
  - "before 9am on tuesday"
- Automerge
  - At any time (no schedule defined)

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Mend Renovate CLI](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0NC4yMjcuNCIsInVwZGF0ZWRJblZlciI6IjQ0LjIyNy40IiwidGFyZ2V0QnJhbmNoIjoiZGV2ZWxvcCIsImxhYmVscyI6WyJkZXBlbmRlbmNpZXMiLCJyZW5vdmF0ZSJdfQ==-->

Reviewed-on: https://code.futo.org/harbor/harbor/pulls/2336
@greptile-apps

greptile-apps Bot commented Nov 18, 2026

Copy link
Copy Markdown
Contributor

Want your agent to iterate on Greptile's feedback? Try greploops.

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::docs The PR is related to docs v1x Version 1

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants