-
Notifications
You must be signed in to change notification settings - Fork 33
Downgrade api-fetch package to 7.29 #3662
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -137,21 +137,18 @@ export abstract class BaseProvider { | |||||||||||||||||||||||||||||||||||||||||
| * AbortController signal. | ||||||||||||||||||||||||||||||||||||||||||
| * | ||||||||||||||||||||||||||||||||||||||||||
| * @since 3.15.0 | ||||||||||||||||||||||||||||||||||||||||||
| * @since 3.20.7 Using APIFetchOptions<true> to avoid a type error when building on GitHub. | ||||||||||||||||||||||||||||||||||||||||||
| * | ||||||||||||||||||||||||||||||||||||||||||
| * @param {APIFetchOptions} options The options to pass to apiFetch. | ||||||||||||||||||||||||||||||||||||||||||
| * @param {string?} id The (optional) ID of the request. | ||||||||||||||||||||||||||||||||||||||||||
| * | ||||||||||||||||||||||||||||||||||||||||||
| * @return {Promise<ContentHelperAPIResponse<any>>} The fetched data. | ||||||||||||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||||||||||||
| protected async fetch<T>( options: APIFetchOptions<true>, id?: string ): Promise<T> { | ||||||||||||||||||||||||||||||||||||||||||
| protected async fetch<T>( options: APIFetchOptions, id?: string ): Promise<T> { | ||||||||||||||||||||||||||||||||||||||||||
| const { abortController, abortId } = this.getOrCreateController( id ); | ||||||||||||||||||||||||||||||||||||||||||
| options.signal = abortController.signal; | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| try { | ||||||||||||||||||||||||||||||||||||||||||
| const response = await apiFetch<ContentHelperAPIResponse<T>>( | ||||||||||||||||||||||||||||||||||||||||||
| options as APIFetchOptions<true> | ||||||||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||||||||
| const response = await apiFetch<ContentHelperAPIResponse<T>>( options ); | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+146
to
152
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Type relaxation reintroduces a runtime hazard; enforce parse=true and avoid mutating caller options. By dropping APIFetchOptions, callers can now pass parse:false and this method would still treat the result as parsed JSON, causing runtime errors. Also, mutating options in place can surprise callers. Apply: - protected async fetch<T>( options: APIFetchOptions, id?: string ): Promise<T> {
+ protected async fetch<T>( options: APIFetchOptions, id?: string ): Promise<T> {
const { abortController, abortId } = this.getOrCreateController( id );
-
- options.signal = abortController.signal;
+ // Enforce JSON parsing and avoid mutating the caller-provided object.
+ const fetchOptions: APIFetchOptions = {
+ ...options,
+ signal: abortController.signal,
+ parse: true,
+ };
try {
- const response = await apiFetch<ContentHelperAPIResponse<T>>( options );
+ const response = await apiFetch<ContentHelperAPIResponse<T>>( fetchOptions );📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||
| // Validate API side errors. | ||||||||||||||||||||||||||||||||||||||||||
| if ( response.error ) { | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Verification agent
🧩 Analysis chain
Pin looks good; consider forcing a single version across the tree and documenting why.
Apply:
"devDependencies": { - "@wordpress/api-fetch": "7.29", + "@wordpress/api-fetch": "7.29", }, + "devDependenciesComments": { + "@wordpress/api-fetch": "Pinned to 7.29 to avoid stricter typing in 7.30 that breaks our build. Do not upgrade until types are refactored." + }, "overrides": { - "puppeteer-core": "^23.1.0" + "puppeteer-core": "^23.1.0", + "@wordpress/api-fetch": "7.29" },Verify no other copy of api-fetch is brought in and no lingering APIFetchOptions remain:
🏁 Script executed:
Length of output: 2630
Force single @wordpress/api-fetch version and document rationale
Multiple transitive deps still pull in @wordpress/api-fetch@7.30.x and @wordpress/api-fetch@6.55.x; add a Yarn
resolutionsblock to pin all instances to 7.29.0 and include a comment:"resolutions": { - // existing overrides... + "@wordpress/api-fetch": "7.29.0" }, + "devDependenciesComments": { + "@wordpress/api-fetch": "Pinned to 7.29.0 to avoid stricter typing in 7.30+ that breaks our build" + }No occurrences of
APIFetchOptions<true>remain.🤖 Prompt for AI Agents