Skip to content

fix: core methodList, HTTP adapter errors, and add tests - #11048

Closed
Mohammad-Faiz-Cloud-Engineer wants to merge 0 commit into
axios:v1.xfrom
Mohammad-Faiz-Cloud-Engineer:v1.x
Closed

Mohammad-Faiz-Cloud-Engineer wants to merge 0 commit into
axios:v1.xfrom
Mohammad-Faiz-Cloud-Engineer:v1.x

Conversation

@Mohammad-Faiz-Cloud-Engineer

@Mohammad-Faiz-Cloud-Engineer Mohammad-Faiz-Cloud-Engineer commented Jun 29, 2026 •

Copy link
Copy Markdown
Contributor
  • Add lib/core/methodList.js and use it in:
    • lib/core/Axios.js for supported method header flattening.
    • lib/defaults/index.js to initialize defaults.headers[method] from the shared method list.
  • Add missing purge, link, unlink to methodList to align with Method type and HeadersDefaults interface.
  • Fix HTTP adapter error handling by replacing raw TypeError instances with AxiosError.
  • Pass config argument to httpVersion AxiosError throws for consistency with other adapter errors.
  • Fix the timeoutMessage typo in mergeConfig.
  • Add unit tests for:
    • defaults.headers[method] existing for all entries in methodList.
    • Invalid address and httpVersion rejecting with AxiosError code ERR_BAD_OPTION_VALUE.
    • mergeConfig preserving timeoutErrorMessage from overrides.

Summary by cubic

Centralizes the HTTP method list in core, normalizes HTTP adapter option errors to AxiosError, and fixes mergeConfig to honor timeoutErrorMessage. Adds tests to lock these behaviors.

  • Changes

    • Added lib/core/methodList.js; used in Axios header flattening and defaults.headers init.
    • Included missing methods: options, purge, link, unlink, query.
    • Replaced TypeError with AxiosError('ERR_BAD_OPTION_VALUE') for invalid address and httpVersion; passed config for httpVersion.
    • Fixed mergeConfig to use timeoutErrorMessage.
  • Notes

    • Docs: update /docs/ to list supported methods, show timeoutErrorMessage, and note adapter validation for httpVersion/address with ERR_BAD_OPTION_VALUE.
    • Tests: added coverage for defaults.headers[method] per methodList, HTTP adapter option errors, and mergeConfig honoring timeoutErrorMessage.
    • Semantic version impact: Patch.

Written for commit cb4fd74. Summary will update on new commits.

Review in 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.

2 issues found across 5 files

Confidence score: 3/5

  • In lib/core/methodList.js, omitting purge, link, and unlink from the shared method list while Axios types/interfaces support them can cause runtime/type drift in method-based header/default handling, so those methods may behave inconsistently after merge — add the missing methods to keep runtime behavior aligned with the declared Axios method surface before merging.
  • In lib/adapters/http.js, the new httpVersion AxiosError paths drop the request config, which makes these failures harder to diagnose and less consistent with other adapter errors; merging as-is risks poorer debugging and error handling in production — include config on these errors to match existing AxiosError conventions before merging.

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

Re-trigger cubic

Comment thread lib/adapters/http.js Resolved
Comment thread lib/core/methodList.js Resolved
@Mohammad-Faiz-Cloud-Engineer Mohammad-Faiz-Cloud-Engineer changed the title fix: core methodList and error handling in HTTP adapter fix: core methodList, HTTP adapter errors, and add tests Jun 29, 2026
@jasonsaayman jasonsaayman added the commit::fix The PR is related to a bugfix label Jul 13, 2026
@jasonsaayman
jasonsaayman requested a review from Copilot July 21, 2026 18:19

Copilot AI 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.

Pull request overview

This PR centralizes the supported HTTP method list in lib/core/, uses it to keep header defaults/flattening consistent, normalizes Node HTTP adapter option-validation failures to AxiosError, and fixes mergeConfig to correctly merge timeoutErrorMessage overrides.

Changes:

  • Added lib/core/methodList.js and reused it for header flattening (lib/core/Axios.js) and defaults.headers[method] initialization (lib/defaults/index.js).
  • Updated lib/adapters/http.js to throw AxiosError (with ERR_BAD_OPTION_VALUE) for invalid address/httpVersion and to include config in httpVersion validation errors.
  • Fixed mergeConfig to merge timeoutErrorMessage (and added focused unit tests for these behaviors).

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
tests/unit/core/mergeConfig.test.js Adds assertions that timeoutErrorMessage merges/overrides correctly.
tests/unit/axios.test.js Adds a unit check that defaults.headers[method] exists and is {} for every method in methodList.
tests/unit/adapters/http.test.js Adds coverage that invalid address and httpVersion reject with AxiosError + ERR_BAD_OPTION_VALUE.
lib/defaults/index.js Initializes defaults.headers[method] via the centralized methodList.
lib/core/methodList.js Introduces a single source of truth for supported methods (including purge/link/unlink).
lib/core/mergeConfig.js Fixes merge map key to timeoutErrorMessage.
lib/core/Axios.js Uses methodList when removing method-specific header buckets during header flattening.
lib/adapters/http.js Replaces raw TypeError option-validation throws with AxiosError and passes config for httpVersion errors.

Comment thread lib/core/methodList.js Resolved
@Mohammad-Faiz-Cloud-Engineer

Copy link
Copy Markdown
Contributor Author

hey i accidently closed my pr i will reopen it.

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

Labels

commit::fix The PR is related to a bugfix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants