Skip to content

SK-2771: fix deidentifyFile crash when waitTime is exceeded before processing completes#296

Merged
Devesh-Skyflow merged 2 commits intorelease/26.4.4from
devesh/SK2771
Apr 23, 2026
Merged

SK-2771: fix deidentifyFile crash when waitTime is exceeded before processing completes#296
Devesh-Skyflow merged 2 commits intorelease/26.4.4from
devesh/SK2771

Conversation

@Devesh-Skyflow
Copy link
Copy Markdown
Collaborator

Problem
When waitTime is small and the file is still processing, the SDK crashed with TypeError: object is not iterable.

The poller resolved with { runId } (object) on timeout but [response, runId] (array) on success — the .then() handler always destructured as an array, causing the crash. A missing return also caused fall-through into response parsing with incomplete data.

Changes
Unified both resolve paths to consistent { data, runId } shape
Switched to named destructuring in .then() handler
Added return after IN_PROGRESS resolve to stop fall-through
Added unit tests for the timeout path
Verification
Tested locally with waitTime: 1 — previously crashed, now returns { runId, status: 'IN_PROGRESS' } cleanly.

@Devesh-Skyflow Devesh-Skyflow requested a review from Copilot April 23, 2026 10:55
@github-actions
Copy link
Copy Markdown

Gitleaks Findings: No secrets detected. Safe to proceed!

@Devesh-Skyflow Devesh-Skyflow changed the base branch from main to release/26.4.4 April 23, 2026 10:55
@github-actions
Copy link
Copy Markdown

Semgrep Findings: Issues with Error level severity are found (Error is Highest severity in Semgrep), Please resolve the issues before merging.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes a crash in deidentifyFile when waitTime expires before the detect run finishes by making the poller resolve shape consistent and preventing fall-through into response parsing on the timeout path.

Changes:

  • Standardized poller resolution to { data, runId } for both timeout and success paths.
  • Updated .then() handling to use named destructuring and added an early return for IN_PROGRESS.
  • Added unit tests covering the timeout / IN_PROGRESS behavior.

Reviewed changes

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

File Description
src/vault/controller/detect/index.ts Unifies poll resolve shape and prevents parsing on timeout (IN_PROGRESS) responses.
test/vault/controller/detect.test.js Adds tests asserting correct return shape and no parsed file data when waitTime is exceeded.
Comments suppressed due to low confidence (1)

src/vault/controller/detect/index.ts:612

  • promiseReq is typed as DeidentifyFileDetectRunResponse & { runId?: string; status?: string }, but the timeout path resolves data with only { runId, status: 'IN_PROGRESS' } (missing required output, outputType, message, etc. from DeidentifyFileDetectRunResponse). This makes the type misleading and can hide real runtime shape differences. Consider introducing a discriminated union for the poll result (e.g., { runId, data: DeidentifyFileDetectRunResponse } | { runId, data: { status: 'IN_PROGRESS' } }) and narrowing in the .then handler, or relaxing data to a Partial<DeidentifyFileDetectRunResponse> with an explicit guard before calling parseDeidentifyFileResponse.
                var reqType : DeidenitfyFileRequestTypes = this.getReqType(fileExtension); 
                var promiseReq: Promise<{ data: DeidentifyFileDetectRunResponse & { runId?: string; status?: string }, runId: string }>;
                switch (reqType){
                    case DeidenitfyFileRequestTypes.AUDIO:
                        promiseReq = this.buildAudioRequest(fileObj, options, fileExtension)
                            .then((audioReq) => {

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/vault/controller/detect/index.ts
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

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


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/vault/controller/detect/index.ts
@Devesh-Skyflow Devesh-Skyflow merged commit 690bfde into release/26.4.4 Apr 23, 2026
5 of 6 checks passed
@Devesh-Skyflow Devesh-Skyflow mentioned this pull request Apr 24, 2026
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.

4 participants