Skip to content

chore: removed axios#7685

Merged
SamTV12345 merged 2 commits intodevelopfrom
feature/remove-axios
May 6, 2026
Merged

chore: removed axios#7685
SamTV12345 merged 2 commits intodevelopfrom
feature/remove-axios

Conversation

@SamTV12345
Copy link
Copy Markdown
Member

No description provided.

@SamTV12345 SamTV12345 force-pushed the feature/remove-axios branch from 6935a10 to e11867c Compare May 6, 2026 20:01
@SamTV12345 SamTV12345 marked this pull request as ready for review May 6, 2026 20:05
@qodo-code-review
Copy link
Copy Markdown

ⓘ You've reached your Qodo monthly free-tier limit. Reviews pause until next month — upgrade your plan to continue now, or link your paid account if you already have one.

@qodo-free-for-open-source-projects
Copy link
Copy Markdown

Review Summary by Qodo

Replace axios HTTP client with native fetch API and undici

✨ Enhancement

Grey Divider

Walkthroughs

Description
• Replace axios HTTP client with native fetch API
• Add undici ProxyAgent for proxy support
• Simplify HTTP request handling across CLI tools
• Remove axios dependency from package.json
Diagram
flowchart LR
  axios["axios HTTP client"] -->|removed| fetch["Native fetch API"]
  fetch -->|used in| cli["CLI tools<br/>compactPad, deletePad, etc."]
  fetch -->|used in| server["Server modules<br/>UpdateCheck, installer"]
  proxy["HTTP proxy support"] -->|replaced| undici["undici ProxyAgent"]
  undici -->|configured in| serverProxy["src/node/server.ts"]
Loading

Grey Divider

File Changes

1. bin/compactAllPads.ts ✨ Enhancement +25/-16

Replace axios with fetch API

bin/compactAllPads.ts


2. bin/compactPad.ts ✨ Enhancement +23/-14

Replace axios with fetch API

bin/compactPad.ts


3. bin/createUserSession.ts ✨ Enhancement +25/-17

Replace axios with fetch API

bin/createUserSession.ts


View more (11)
4. bin/deleteAllGroupSessions.ts ✨ Enhancement +21/-13

Replace axios with fetch API

bin/deleteAllGroupSessions.ts


5. bin/deletePad.ts ✨ Enhancement +16/-7

Replace axios with fetch API

bin/deletePad.ts


6. bin/plugins/stalePlugins.ts ✨ Enhancement +7/-9

Replace axios with fetch API

bin/plugins/stalePlugins.ts


7. src/node/server.ts ✨ Enhancement +5/-23

Replace axios proxy with undici ProxyAgent

src/node/server.ts


8. src/node/utils/UpdateCheck.ts ✨ Enhancement +4/-4

Replace axios with fetch API

src/node/utils/UpdateCheck.ts


9. src/static/js/pluginfw/installer.ts ✨ Enhancement +5/-3

Replace axios with fetch API

src/static/js/pluginfw/installer.ts


10. src/tests/backend/fuzzImportTest.ts ✨ Enhancement +24/-28

Replace axios with fetch API

src/tests/backend/fuzzImportTest.ts


11. src/tests/backend/specs/compactPad.ts 📝 Documentation +2/-2

Update comments referencing axios

src/tests/backend/specs/compactPad.ts


12. bin/package.json Dependencies +0/-1

Remove axios dependency

bin/package.json


13. src/package.json Dependencies +1/-1

Remove axios, add undici dependency

src/package.json


14. pnpm-lock.yaml Dependencies +7/-39

Update lock file removing axios

pnpm-lock.yaml


Grey Divider

Qodo Logo

@qodo-free-for-open-source-projects
Copy link
Copy Markdown

qodo-free-for-open-source-projects Bot commented May 6, 2026

Code Review by Qodo

🐞 Bugs (1) 📘 Rule violations (1)

Grey Divider


Action required

1. runTest() uses 4-space indent 📘 Rule violation ⚙ Maintainability
Description
New code in runTest() is indented with 4 spaces instead of the required 2 spaces. This violates
the repository indentation standard and reduces formatting consistency.
Code

src/tests/backend/fuzzImportTest.ts[R30-57]

+    try {
+        const createRes = await fetch(`${host + endPoint('createPad')}?padID=${testPadId}`, {
            headers: {
                Authorization: await common.generateJWTToken(),
-            }
-        })
-        .then(() => {
-            const req = axios.post(`${host}/p/${testPadId}/import`)
-                .then(() => {
-                    console.log('Success');
-                    let fN = '/test.txt';
-                    let cT = 'text/plain';
+            },
+        });
+        if (!createRes.ok) throw new Error(`createPad HTTP ${createRes.status}`);

-                    // To be more aggressive every other test we mess with Etherpad
-                    // We provide a weird file name and also set a weird contentType
-                    if (number % 2 == 0) {
-                        fN = froth().toString();
-                        cT = froth().toString();
-                    }
+        let fN = '/test.txt';
+        let cT = 'text/plain';
+        // To be more aggressive every other test we mess with Etherpad
+        // We provide a weird file name and also set a weird contentType
+        if (number % 2 == 0) {
+            fN = froth().toString();
+            cT = froth().toString();
+        }

-                    const form = req.form();
-                    form.append('file', froth().toString(), {
-                        filename: fN,
-                        contentType: cT,
-                    });
-                });
-        })
-        .catch((err:any) => {
-        // @ts-ignore
-            throw new Error('FAILURE', err);
-    })
+        const form = new FormData();
+        form.append('file', new Blob([froth().toString()], {type: cT}), fN);
+        const importRes = await fetch(`${host}/p/${testPadId}/import`, {
+            method: 'POST',
+            body: form,
+        });
+        if (!importRes.ok) throw new Error(`import HTTP ${importRes.status}`);
+        console.log('Success');
+    } catch (err: any) {
+        throw new Error('FAILURE', err);
+    }
Evidence
PR Compliance ID 6 requires 2-space indentation and no tabs. The added block under runTest() shows
4-space indentation (for example, +    try { and subsequent lines).

src/tests/backend/fuzzImportTest.ts[30-57]
Best Practice: Repository guidelines

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The new `runTest()` code block in `src/tests/backend/fuzzImportTest.ts` is indented with 4 spaces, violating the project requirement of 2-space indentation.

## Issue Context
This PR introduces new `try/catch` + `fetch` + `FormData` logic and the added lines are formatted with 4-space indentation.

## Fix Focus Areas
- src/tests/backend/fuzzImportTest.ts[30-57]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools



Remediation recommended

2. API errors misclassified 🐞 Bug ≡ Correctness
Description
bin/createUserSession.ts only treats res.code === 1 as an error, so non-zero codes like 2/3/4 will
be treated as success and the script will continue using res.data (which can be null). This can
lead to misleading output or runtime failures when subsequent calls use undefined IDs.
Code

bin/createUserSession.ts[R45-47]

+  res = await apiPost(uri('createGroup', {apikey}));
+  if (res.code === 1) throw new Error(`Error creating group: ${res}`);
+  const groupID = res.data.groupID;
Evidence
The REST API wrapper returns {code: 0, data: ...} on success and maps various failures to non-zero
codes (1/2/3/4) with data: null. Therefore, checking only for code === 1 will miss other
failures and can cause null dereferences or incorrect behavior.

bin/createUserSession.ts[45-57]
src/node/handler/RestAPI.ts[1485-1489]
src/node/handler/RestAPI.ts[1512-1534]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
`bin/createUserSession.ts` treats only `res.code === 1` as an error. Etherpad’s REST API uses multiple non-zero codes (1/2/3/4), and on error it sets `data: null`, so the script can proceed with `null` data and fail later or print misleading output.

### Issue Context
The REST API response wrapper is implemented in `src/node/handler/RestAPI.ts`.

### Fix Focus Areas
- bin/createUserSession.ts[45-65]
- src/node/handler/RestAPI.ts[1485-1490]
- src/node/handler/RestAPI.ts[1512-1534]

### What to change
- Replace all `if (res.code === 1)` checks with `if (res.code !== 0)`.
- When `res.code !== 0`, throw an error that includes `res.code` and `res.message` (and optionally `JSON.stringify(res)`), and do **not** access `res.data`.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

Qodo Logo

@SamTV12345 SamTV12345 merged commit bfdbd2b into develop May 6, 2026
39 of 40 checks passed
@SamTV12345 SamTV12345 deleted the feature/remove-axios branch May 6, 2026 20:06
Comment on lines +30 to +57
try {
const createRes = await fetch(`${host + endPoint('createPad')}?padID=${testPadId}`, {
headers: {
Authorization: await common.generateJWTToken(),
}
})
.then(() => {
const req = axios.post(`${host}/p/${testPadId}/import`)
.then(() => {
console.log('Success');
let fN = '/test.txt';
let cT = 'text/plain';
},
});
if (!createRes.ok) throw new Error(`createPad HTTP ${createRes.status}`);

// To be more aggressive every other test we mess with Etherpad
// We provide a weird file name and also set a weird contentType
if (number % 2 == 0) {
fN = froth().toString();
cT = froth().toString();
}
let fN = '/test.txt';
let cT = 'text/plain';
// To be more aggressive every other test we mess with Etherpad
// We provide a weird file name and also set a weird contentType
if (number % 2 == 0) {
fN = froth().toString();
cT = froth().toString();
}

const form = req.form();
form.append('file', froth().toString(), {
filename: fN,
contentType: cT,
});
});
})
.catch((err:any) => {
// @ts-ignore
throw new Error('FAILURE', err);
})
const form = new FormData();
form.append('file', new Blob([froth().toString()], {type: cT}), fN);
const importRes = await fetch(`${host}/p/${testPadId}/import`, {
method: 'POST',
body: form,
});
if (!importRes.ok) throw new Error(`import HTTP ${importRes.status}`);
console.log('Success');
} catch (err: any) {
throw new Error('FAILURE', err);
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Action required

1. runtest() uses 4-space indent 📘 Rule violation ⚙ Maintainability

New code in runTest() is indented with 4 spaces instead of the required 2 spaces. This violates
the repository indentation standard and reduces formatting consistency.
Agent Prompt
## Issue description
The new `runTest()` code block in `src/tests/backend/fuzzImportTest.ts` is indented with 4 spaces, violating the project requirement of 2-space indentation.

## Issue Context
This PR introduces new `try/catch` + `fetch` + `FormData` logic and the added lines are formatted with 4-space indentation.

## Fix Focus Areas
- src/tests/backend/fuzzImportTest.ts[30-57]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant