From d6123437f3154215827237cdcd7f7ca6a9b7851d Mon Sep 17 00:00:00 2001 From: Devesh-Skyflow Date: Thu, 23 Apr 2026 16:22:57 +0530 Subject: [PATCH 1/9] SK-2771: fix deidentifyFile() throws `object is not iterable` when waitTime is small --- src/vault/controller/detect/index.ts | 9 ++--- test/vault/controller/detect.test.js | 50 ++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+), 4 deletions(-) diff --git a/src/vault/controller/detect/index.ts b/src/vault/controller/detect/index.ts index 83672c11..b39030e7 100644 --- a/src/vault/controller/detect/index.ts +++ b/src/vault/controller/detect/index.ts @@ -352,7 +352,7 @@ class DetectController { if (response.status?.toUpperCase() === 'IN_PROGRESS' ) { if (currentWaitTime >= maxWaitTime) { - resolve({ runId }); // Resolve with runId if max wait time is exceeded + resolve({ data: { runId, status: 'IN_PROGRESS' }, runId }); } else { const nextWaitTime = currentWaitTime * 2; let waitTime = 0; @@ -368,7 +368,7 @@ class DetectController { }, waitTime * 1000); } } else if (response.status?.toUpperCase() === 'SUCCESS') { - resolve([response, runId]); // Resolve with the processed file response and runId + resolve({ data: response, runId }); } else if (response.status?.toUpperCase() === 'FAILED') { reject(new SkyflowError(SKYFLOW_ERROR_CODE.INTERNAL_SERVER_ERROR, [response.message])); @@ -605,7 +605,7 @@ class DetectController { this.waitTime = options?.getWaitTime() ?? this.waitTime; var reqType : DeidenitfyFileRequestTypes = this.getReqType(fileExtension); - var promiseReq: Promise<[DeidentifyFileDetectRunResponse, string]>; + var promiseReq: Promise<{ data: DeidentifyFileDetectRunResponse & { runId?: string; status?: string }, runId: string }>; switch (reqType){ case DeidenitfyFileRequestTypes.AUDIO: promiseReq = this.buildAudioRequest(fileObj, options, fileExtension) @@ -708,12 +708,13 @@ class DetectController { break; } - promiseReq.then(([data, runId]) => { + promiseReq.then(({ data, runId }) => { if(runId && data.status === "IN_PROGRESS") { resolve(new DeidentifyFileResponse({ runId: runId, status: data.status, })); + return; } if (options?.getOutputDirectory() && data.status === "SUCCESS") { this.processDeidentifyFileResponse(data, options.getOutputDirectory() as string, fileBaseName); diff --git a/test/vault/controller/detect.test.js b/test/vault/controller/detect.test.js index bb313469..9b4d9fd1 100644 --- a/test/vault/controller/detect.test.js +++ b/test/vault/controller/detect.test.js @@ -1059,4 +1059,54 @@ describe('deidentifyFile', () => { expect.any(Buffer) ); }); + + test('should return runId and IN_PROGRESS status when waitTime is exceeded before processing completes', async () => { + const file = new File(['dummy content'], 'test.pdf', { type: 'application/pdf' }); + const request = new DeidentifyFileRequest({ file }); + const options = new DeidentifyFileOptions(); + options.setWaitTime(1); // very small waitTime — will expire immediately + + mockVaultClient.filesAPI.deidentifyPdf.mockImplementation(() => ({ + withRawResponse: jest.fn().mockResolvedValue({ + data: { run_id: 'run123' }, + rawResponse: { headers: { get: jest.fn().mockReturnValue('req-id') } }, + }), + })); + + // Always IN_PROGRESS — never finishes within waitTime + mockVaultClient.filesAPI.getRun.mockResolvedValue({ status: 'IN_PROGRESS' }); + + const promise = detectController.deidentifyFile(request, options); + await jest.runAllTimersAsync(); + const result = await promise; + + expect(result.runId).toBe('run123'); + expect(result.status).toBe('IN_PROGRESS'); + }); + + test('should not call parseDeidentifyFileResponse when waitTime is exceeded (IN_PROGRESS early return)', async () => { + const file = new File(['dummy content'], 'test.pdf', { type: 'application/pdf' }); + const request = new DeidentifyFileRequest({ file }); + const options = new DeidentifyFileOptions(); + options.setWaitTime(1); + + mockVaultClient.filesAPI.deidentifyPdf.mockImplementation(() => ({ + withRawResponse: jest.fn().mockResolvedValue({ + data: { run_id: 'run456' }, + rawResponse: { headers: { get: jest.fn().mockReturnValue('req-id') } }, + }), + })); + + mockVaultClient.filesAPI.getRun.mockResolvedValue({ status: 'IN_PROGRESS' }); + + const promise = detectController.deidentifyFile(request, options); + await jest.runAllTimersAsync(); + const result = await promise; + + // Only runId and status should be set — no file data + expect(result.runId).toBe('run456'); + expect(result.status).toBe('IN_PROGRESS'); + expect(result.fileBase64).toBeUndefined(); + expect(result.extension).toBeUndefined(); + }); }); \ No newline at end of file From e845ba31f48ac8256facd9d4863d0cb0a9944a85 Mon Sep 17 00:00:00 2001 From: Devesh-Skyflow Date: Thu, 23 Apr 2026 17:09:35 +0530 Subject: [PATCH 2/9] fix: type --- src/vault/controller/detect/index.ts | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/vault/controller/detect/index.ts b/src/vault/controller/detect/index.ts index b39030e7..9c69c6bb 100644 --- a/src/vault/controller/detect/index.ts +++ b/src/vault/controller/detect/index.ts @@ -352,7 +352,7 @@ class DetectController { if (response.status?.toUpperCase() === 'IN_PROGRESS' ) { if (currentWaitTime >= maxWaitTime) { - resolve({ data: { runId, status: 'IN_PROGRESS' }, runId }); + resolve({ data: { status: 'IN_PROGRESS' }, runId }); } else { const nextWaitTime = currentWaitTime * 2; let waitTime = 0; @@ -605,7 +605,10 @@ class DetectController { this.waitTime = options?.getWaitTime() ?? this.waitTime; var reqType : DeidenitfyFileRequestTypes = this.getReqType(fileExtension); - var promiseReq: Promise<{ data: DeidentifyFileDetectRunResponse & { runId?: string; status?: string }, runId: string }>; + type PollResult = + | { data: DeidentifyFileDetectRunResponse; runId: string } + | { data: { status: string }; runId: string }; + var promiseReq: Promise; switch (reqType){ case DeidenitfyFileRequestTypes.AUDIO: promiseReq = this.buildAudioRequest(fileObj, options, fileExtension) @@ -716,10 +719,11 @@ class DetectController { })); return; } - if (options?.getOutputDirectory() && data.status === "SUCCESS") { - this.processDeidentifyFileResponse(data, options.getOutputDirectory() as string, fileBaseName); + const fullResponse = data as DeidentifyFileDetectRunResponse; + if (options?.getOutputDirectory() && fullResponse.status === "SUCCESS") { + this.processDeidentifyFileResponse(fullResponse, options.getOutputDirectory() as string, fileBaseName); } - const deidentifiedFileResponse = this.parseDeidentifyFileResponse(data, runId, data.status); + const deidentifiedFileResponse = this.parseDeidentifyFileResponse(fullResponse, runId, fullResponse.status); resolve(deidentifiedFileResponse); }).catch(error => { reject(error) From faf864af26e60876f4ad387837a3543001b53d34 Mon Sep 17 00:00:00 2001 From: Devesh-Skyflow Date: Thu, 23 Apr 2026 12:57:19 +0000 Subject: [PATCH 3/9] [AUTOMATED] Private Release 1.14.3-dev.50a2bba --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index ba2b35e2..3aed70f9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "skyflow-node", - "version": "2.0.2-dev.2a81ccd", + "version": "1.14.3-dev.50a2bba", "description": "Skyflow SDK for Node.js", "main": "./lib/index.js", "module": "./lib/index.js", From 4fadc7a48304e88456fa6b8dc530d31e07b8b81a Mon Sep 17 00:00:00 2001 From: Devesh-Skyflow Date: Thu, 23 Apr 2026 18:36:55 +0530 Subject: [PATCH 4/9] fix: internal release flow --- .github/workflows/common-release.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/common-release.yml b/.github/workflows/common-release.yml index 600fc231..cbdba634 100644 --- a/.github/workflows/common-release.yml +++ b/.github/workflows/common-release.yml @@ -86,10 +86,13 @@ jobs: npm publish fi elif [[ "${{ inputs.tag }}" == "internal" ]]; then - curl -u ${{ secrets.JFROG_USERNAME }}:${{ secrets.JFROG_PASSWORD }} https://prekarilabs.jfrog.io/prekarilabs/api/npm/auth/ > ~/.npmrc + JFROG_AUTH=$(echo -n "$JFROG_USERNAME:$JFROG_PASSWORD" | base64 -w 0) npm config set registry https://prekarilabs.jfrog.io/prekarilabs/api/npm/npm/ - npm config fix + npm config set //prekarilabs.jfrog.io/prekarilabs/api/npm/npm/:_auth "$JFROG_AUTH" + npm config set //prekarilabs.jfrog.io/prekarilabs/api/npm/npm/:always-auth true npm publish fi env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + JFROG_USERNAME: ${{ secrets.JFROG_USERNAME }} + JFROG_PASSWORD: ${{ secrets.JFROG_PASSWORD }} From b36c77d5d9fcbd8a928c71720205ff872046a2b7 Mon Sep 17 00:00:00 2001 From: Devesh-Skyflow Date: Thu, 23 Apr 2026 13:18:22 +0000 Subject: [PATCH 5/9] [AUTOMATED] Private Release 1.14.3-dev.4fadc7a --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 3aed70f9..babd514d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "skyflow-node", - "version": "1.14.3-dev.50a2bba", + "version": "1.14.3-dev.4fadc7a", "description": "Skyflow SDK for Node.js", "main": "./lib/index.js", "module": "./lib/index.js", From 7561fe6d2a6acb19c131c4e2a54ccd9aca9d222b Mon Sep 17 00:00:00 2001 From: Devesh-Skyflow Date: Thu, 23 Apr 2026 19:09:23 +0530 Subject: [PATCH 6/9] fix build --- .github/workflows/common-release.yml | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/.github/workflows/common-release.yml b/.github/workflows/common-release.yml index cbdba634..8a234b62 100644 --- a/.github/workflows/common-release.yml +++ b/.github/workflows/common-release.yml @@ -12,11 +12,11 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v2 with: token: ${{ secrets.PAT_ACTIONS }} fetch-depth: 0 - - uses: actions/setup-node@v4 + - uses: actions/setup-node@v1 with: node-version: '20.x' registry-url: "https://registry.npmjs.org" @@ -32,10 +32,10 @@ jobs: uses: WyriHaximus/github-action-get-previous-tag@v1 with: fallback: 1.0.0 - + - name: Resolve Branch Name id: resolve-branch - if: ${{ inputs.tag == 'beta' || inputs.tag == 'public' }} + if: ${{ inputs.tag == 'beta' || inputs.tag == 'public' }} run: | TAG_COMMIT=$(git rev-list -n 1 ${{ github.ref_name }}) @@ -86,13 +86,10 @@ jobs: npm publish fi elif [[ "${{ inputs.tag }}" == "internal" ]]; then - JFROG_AUTH=$(echo -n "$JFROG_USERNAME:$JFROG_PASSWORD" | base64 -w 0) + curl -u ${{ secrets.JFROG_USERNAME }}:${{ secrets.JFROG_PASSWORD }} https://prekarilabs.jfrog.io/prekarilabs/api/npm/auth/ > ~/.npmrc npm config set registry https://prekarilabs.jfrog.io/prekarilabs/api/npm/npm/ - npm config set //prekarilabs.jfrog.io/prekarilabs/api/npm/npm/:_auth "$JFROG_AUTH" - npm config set //prekarilabs.jfrog.io/prekarilabs/api/npm/npm/:always-auth true + npm config fix npm publish fi env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} - JFROG_USERNAME: ${{ secrets.JFROG_USERNAME }} - JFROG_PASSWORD: ${{ secrets.JFROG_PASSWORD }} From 9a51782ea800bb2ae4ea6e31f9c4fda7a76d3d2c Mon Sep 17 00:00:00 2001 From: Devesh-Skyflow Date: Thu, 23 Apr 2026 13:39:49 +0000 Subject: [PATCH 7/9] [AUTOMATED] Private Release 1.14.3-dev.7561fe6 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index babd514d..4240263b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "skyflow-node", - "version": "1.14.3-dev.4fadc7a", + "version": "1.14.3-dev.7561fe6", "description": "Skyflow SDK for Node.js", "main": "./lib/index.js", "module": "./lib/index.js", From 2f42cd8a776d3f64714f3519733648e2513fcf36 Mon Sep 17 00:00:00 2001 From: Devesh-Skyflow Date: Thu, 23 Apr 2026 19:33:45 +0530 Subject: [PATCH 8/9] fix: internal release --- .github/workflows/common-release.yml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/workflows/common-release.yml b/.github/workflows/common-release.yml index 8a234b62..2c2027fd 100644 --- a/.github/workflows/common-release.yml +++ b/.github/workflows/common-release.yml @@ -12,11 +12,11 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 with: token: ${{ secrets.PAT_ACTIONS }} fetch-depth: 0 - - uses: actions/setup-node@v1 + - uses: actions/setup-node@v4 with: node-version: '20.x' registry-url: "https://registry.npmjs.org" @@ -86,10 +86,12 @@ jobs: npm publish fi elif [[ "${{ inputs.tag }}" == "internal" ]]; then - curl -u ${{ secrets.JFROG_USERNAME }}:${{ secrets.JFROG_PASSWORD }} https://prekarilabs.jfrog.io/prekarilabs/api/npm/auth/ > ~/.npmrc + JFROG_AUTH=$(echo -n "$JFROG_USERNAME:$JFROG_PASSWORD" | base64 -w 0) npm config set registry https://prekarilabs.jfrog.io/prekarilabs/api/npm/npm/ - npm config fix + npm config set //prekarilabs.jfrog.io/prekarilabs/api/npm/npm/:_auth "$JFROG_AUTH" npm publish fi env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + JFROG_USERNAME: ${{ secrets.JFROG_USERNAME }} + JFROG_PASSWORD: ${{ secrets.JFROG_PASSWORD }} From 09f4b4294a51936479f215196483b144187fdc0a Mon Sep 17 00:00:00 2001 From: Devesh-Skyflow Date: Thu, 23 Apr 2026 14:04:08 +0000 Subject: [PATCH 9/9] [AUTOMATED] Private Release 1.14.3-dev.2f42cd8 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 4240263b..96f6b4c2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "skyflow-node", - "version": "1.14.3-dev.7561fe6", + "version": "1.14.3-dev.2f42cd8", "description": "Skyflow SDK for Node.js", "main": "./lib/index.js", "module": "./lib/index.js",