Skip to content

chore(frontend): downloading workflows as a ZIP no longer saves each one individually - #7611

Merged
aglinxinyuan merged 1 commit into
apache:mainfrom
eugenegujing:chore/download-zip-duplicate-saves
Aug 13, 2026
Merged

aglinxinyuan merged 1 commit into
apache:mainfrom
eugenegujing:chore/download-zip-duplicate-saves

Conversation

@eugenegujing

Copy link
Copy Markdown
Contributor

What changes were proposed in this PR?

Selecting several workflows and using the toolbar's "Download added workflow as a ZIP file" action saved one loose .json file per selected workflow in addition to the archive, so N selected workflows produced N+1 downloads.

Root cause is in frontend/src/app/dashboard/service/user/download/download.service.ts. downloadWorkflow(id, name) both retrieves a workflow and saves it to disk — the save is the tap(this.saveFile.bind(this)) at the end of the pipe — which is exactly what the per-row download action needs. createWorkflowsZip reused that same method purely to obtain each blob, so the save fired for every entry before the blob was added to the archive.

This is a regression rather than intended behaviour: before #2920 (57984370c, "Refactor Frontend to Centralize Downloads Using DownloadService") the bulk path assembled the zip inline and called saveAs exactly once. That refactor moved the logic into DownloadService and reused downloadWorkflow for retrieval, inheriting its save side effect.

The fix splits retrieval from saving:

  • new private retrieveWorkflowItem(id, name) returns the DownloadableItem (blob + file name) without saving — it is the former body of downloadWorkflow minus the tap;
  • downloadWorkflow is now retrieveWorkflowItem(...).pipe(tap(this.saveFile.bind(this))), i.e. behaviour is unchanged for the three per-row callers (user-workflow-list-item.component.ts, list-item.component.ts, card-item.component.ts), which subscribe without a value handler and rely solely on that side effect;
  • createWorkflowsZip calls retrieveWorkflowItem directly.

A.pipe(map, tap) and A.pipe(map).pipe(tap) compose the same chain, so the emitted value, timing, subscription semantics and error propagation of downloadWorkflow are unchanged. The public API is untouched and no call site needed updating.

Before — three workflows selected, then "Download as ZIP": the archive plus test1.json, test2.json, test3.json, four files in total.

Screenshot 2026-08-12 at 3 48 45 PM

After — same three workflows, same action: only workflowExports-*.zip.

Screenshot 2026-08-12 at 4 43 38 PM

Any related issues, documentation, discussions?

Closes #7608

How was this PR tested?

Seven cases were added to frontend/src/app/dashboard/service/user/download/download.service.spec.ts (23 → 30). Three of them fail on main and pass with this change.

Pinning the fix:

  • saves only the zip, not one JSON per workflow, when several workflows are zipped — three workflows, asserts saveAs is called exactly once with the archive, and that no Alpha.json / Beta.json / Gamma.json was saved
  • saves only the zip for a single-workflow selection — the N=1 boundary, which a plain "one extra file" check would miss

Guarding the other direction, so the bug cannot be "fixed" by deleting the save:

  • still saves the file when a single workflow is downloaded on its own — passes before and after; it fails if downloadWorkflow stops saving, which would break the per-row download action

Edge cases:

  • saves nothing when one of the workflows fails to retrieve — the archive aborts as a whole, so the workflows that did come back must not be left behind as loose files (previously they were already saved by the time forkJoin errored)
  • writes the workflow content into the zip entries — reads an entry back out of the produced archive and parses it, since the pre-existing tests only asserted entry names
  • does not save anything when the standalone workflow download fails — error propagates, nothing is written; mirrors the existing dataset / single-file error cases
  • saves nothing for an empty selection — forkJoin([]) completes without emitting, so nothing is retrieved and no empty archive is written (the toolbar already guards this case)
cd frontend
node --max-old-space-size=8192 ./node_modules/@angular/cli/bin/ng test --watch=false \
  --include="src/app/dashboard/service/user/download/download.service.spec.ts"

Test Files 1 passed (1) / Tests 30 passed (30). Reverting only the source change makes exactly three of them fail.

The specs of the three components that depend on downloadWorkflow still saving were also run and pass unchanged (list-item, card-item, user-workflow-list-item).

Manually verified against a local stack, as shown in the screenshots above: create three workflows, select them, click the ZIP download action, and compare the browser's download list before and after the change.

Was this PR authored or co-authored using generative AI tooling?

Co-authored by: Claude Code (Claude Opus 5)

…one individually

Split retrieval from saving in DownloadService by extracting a private retrieveWorkflowItem that createWorkflowsZip uses instead of downloadWorkflow, so a ZIP download writes one file rather than N+1, and pinned the behavior with regression tests.
@github-actions

Copy link
Copy Markdown
Contributor

Automated Reviewer Suggestions

Based on the git blame history of the changed files, we recommend the following reviewers:

  • Contributors with relevant context: @aglinxinyuan
    You can notify them by mentioning @aglinxinyuan in a comment.

@github-actions github-actions Bot added the frontend Changes related to the frontend GUI label Aug 13, 2026
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 88.89%. Comparing base (7daf8d7) to head (1e075b9).
⚠️ Report is 3 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #7611      +/-   ##
============================================
+ Coverage     88.63%   88.89%   +0.25%     
  Complexity     4346     4346              
============================================
  Files          1177     1177              
  Lines         46896    46893       -3     
  Branches       5230     5229       -1     
============================================
+ Hits          41568    41687     +119     
+ Misses         3568     3457     -111     
+ Partials       1760     1749      -11     
Flag Coverage Δ *Carryforward flag
access-control-service 70.00% <ø> (ø) Carriedforward from 7daf8d7
agent-service 98.62% <ø> (ø) Carriedforward from 7daf8d7
amber 84.71% <ø> (ø) Carriedforward from 7daf8d7
computing-unit-managing-service 60.38% <ø> (ø) Carriedforward from 7daf8d7
config-service 77.31% <ø> (ø) Carriedforward from 7daf8d7
file-service 69.05% <ø> (ø) Carriedforward from 7daf8d7
frontend 90.57% <100.00%> (+0.59%) ⬆️
notebook-migration-service 78.89% <ø> (ø) Carriedforward from 7daf8d7
pyamber 97.52% <ø> (ø) Carriedforward from 7daf8d7
workflow-compiling-service 57.89% <ø> (ø) Carriedforward from 7daf8d7

*This pull request uses carry forward flags. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@aglinxinyuan
aglinxinyuan added this pull request to the merge queue Aug 13, 2026
Merged via the queue into apache:main with commit 310ab88 Aug 13, 2026
25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

frontend Changes related to the frontend GUI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Downloading several workflows as a ZIP also saves every one of them as a separate .json file

3 participants