refactor(actions): fix document download helper contract
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
import axios from "axios";
|
||||
import { BASE_URL } from "../core/env";
|
||||
import { consoleLogger } from "../core/logger";
|
||||
import { hashAPIPath } from "../core/hash";
|
||||
@@ -334,26 +333,20 @@ export const deleteRepBlob = async (
|
||||
};
|
||||
|
||||
export const downloadBlob = (containerName, blobName) => {
|
||||
return axios
|
||||
.get(
|
||||
BASE_URL +
|
||||
"/api/file/downloadblob?container=" +
|
||||
containerName.toLowerCase() +
|
||||
"&blobname=" +
|
||||
blobName,
|
||||
{ responseType: "blob" }
|
||||
)
|
||||
.then((response) => {
|
||||
res.setHeader(
|
||||
"content-disposition",
|
||||
"attachment; filename=" + blobName
|
||||
);
|
||||
const queryUrl =
|
||||
BASE_URL +
|
||||
"/api/file/downloadblob?container=" +
|
||||
containerName.toLowerCase() +
|
||||
"&blobname=" +
|
||||
blobName;
|
||||
|
||||
return res.status(200).send(response.data);
|
||||
})
|
||||
.catch((error) => {
|
||||
consoleLogger(error);
|
||||
});
|
||||
return requestJson({
|
||||
method: "get",
|
||||
url: queryUrl,
|
||||
responseType: "blob"
|
||||
}).catch((error) => {
|
||||
consoleLogger(error);
|
||||
});
|
||||
};
|
||||
|
||||
export const getProgressFromBlob = async (containerName, casereference) => {
|
||||
|
||||
@@ -1991,3 +1991,31 @@ Validation:
|
||||
Follow-ups:
|
||||
|
||||
- Optional next bounded slice: isolate and correct `downloadBlob` behavior in `documentDirectService` (including legacy `res` usage) behind an explicit, tested contract.
|
||||
|
||||
---
|
||||
|
||||
### CL-056: TASK22260 next slice — document direct service download helper contract fix
|
||||
|
||||
date: 2026-03-25
|
||||
author: Cline
|
||||
scope: `actions/services/documentDirectService.js`
|
||||
type: change
|
||||
rationale: Execute the next bounded follow-up by correcting the legacy `downloadBlob` service helper path that still relied on invalid `res` references and direct axios usage, aligning it to shared request client behavior.
|
||||
impact: Fixes a service-layer contract defect risk in document download helper and improves consistency by using shared request client patterns; no endpoint contract change.
|
||||
status: completed
|
||||
|
||||
Summary:
|
||||
|
||||
- Refactored `downloadBlob(containerName, blobName)` in `documentDirectService`:
|
||||
- removed legacy direct `axios.get(...).then(response => res.status(...))` pattern that referenced undefined `res` in service layer
|
||||
- now returns blob response data via `requestJson({ method: "get", url, responseType: "blob" })`
|
||||
- preserved catch-path logging (`consoleLogger`)
|
||||
- Removed now-unused module-level `axios` import from `documentDirectService`.
|
||||
|
||||
Validation:
|
||||
|
||||
- `npm run lint` -> warnings only (pre-existing `react-hooks/exhaustive-deps`; no new lint errors)
|
||||
|
||||
Follow-ups:
|
||||
|
||||
- Optional next bounded slice: add a focused test (or integration harness assertion) around `downloadBlob` service return contract to prevent regression to response-object assumptions.
|
||||
|
||||
Reference in New Issue
Block a user