Skip to content

MWPW-197349: Bulk version/revert follow-up — snapshot recording at project save time - #1039

Open
seanchoi0 wants to merge 24 commits into
mainfrom
MWPW-197349
Open

MWPW-197349: Bulk version/revert follow-up — snapshot recording at project save time#1039
seanchoi0 wants to merge 24 commits into
mainfrom
MWPW-197349

Conversation

@seanchoi0

Copy link
Copy Markdown
Contributor

Record a snapshot (non-translation CF version ID) every time a bulk publish project is saved, so that bulk publish can use it as the revert target instead of the pre-publish state. Translation versions (identified by createdBy === 'odin-cf-versioning-user' or comment.startsWith('Pre-rollout snapshot')) are skipped when finding the revert target.

Resolves https://jira.corp.adobe.com/browse/MWPW-197349
QA Checklist: https://wiki.corp.adobe.com/display/adobedotcom/M@S+Engineering+QA+Use+Cases

  • C1. Cover code with Unit Tests
  • C2. Add a Nala test (double check with #fishbags if nala test is needed)
  • C3. Verify all Checks are green (unit tests, nala tests)
  • C4. PR description contains working Test Page link where the feature can be tested
  • C5: you are ready to do a demo from Test Page in PR (bonus: write a working demo script that you'll use on Thursday, you can eventually put in your PR)
  • C.6 read your Jira one more time to validate that you've addressed all AC's and nothing is missing

Test URLs:

@aem-code-sync

aem-code-sync Bot commented Jul 13, 2026

Copy link
Copy Markdown

Hello, I'm the AEM Code Sync Bot and I will run some actions to deploy your branch.
In case there are problems, just click the checkbox below to rerun the respective action.

  • Re-sync branch
Commits

@codecov

codecov Bot commented Jul 13, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 98.96907% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 90.13%. Comparing base (c18e9db) to head (942592f).

Files with missing lines Patch % Lines
io/studio/src/bulk-publish/snapshot.js 97.46% 2 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1039      +/-   ##
==========================================
- Coverage   90.16%   90.13%   -0.03%     
==========================================
  Files         303      304       +1     
  Lines       96759    96932     +173     
==========================================
+ Hits        87246    87373     +127     
- Misses       9513     9559      +46     
Files with missing lines Coverage Δ
io/studio/src/bulk-publish/bulk-publish-worker.js 99.43% <100.00%> (+0.11%) ⬆️
io/studio/src/bulk-publish/save-snapshot-action.js 100.00% <100.00%> (ø)
studio/src/bulk-publish/bulk-publish-client.js 97.01% <100.00%> (+0.29%) ⬆️
studio/src/bulk-publish/bulk-publish-store.js 100.00% <100.00%> (ø)
studio/src/bulk-publish/mas-bulk-publish-editor.js 89.64% <100.00%> (+0.26%) ⬆️
io/studio/src/bulk-publish/snapshot.js 99.09% <97.46%> (-0.91%) ⬇️

... and 12 files with indirect coverage changes


Continue to review full report in Codecov by Harness.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c18e9db...942592f. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@Axelcureno Axelcureno left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Reviewed the snapshot-at-save flow end to end — all 50 IO tests pass and the serialize/deserialize contract with revertSnapshot is consistent. Requesting two tests for scenarios where a future change could silently regress the revert target. Non-blocking.

Comment thread io/studio/src/bulk-publish/snapshot.js
Comment thread io/studio/src/bulk-publish/bulk-publish-worker.js
@seanchoi0
seanchoi0 requested a review from a team July 16, 2026 14:42
Comment thread io/studio/src/bulk-publish/snapshot.js Outdated
Comment thread studio/src/bulk-publish/mas-bulk-publish-editor.js Outdated
Comment thread studio/src/bulk-publish/mas-bulk-publish-editor.js Outdated
…nd await snapshot

- recordSnapshot now collects per-fragment failures instead of throwing,
  returning { entries, failures } to match the revertSnapshot pattern
- save-snapshot-action writes lastError to project when fragments fail
- bulk-publish-worker destructures { entries, failures } from recordSnapshot
- mas-bulk-publish-editor awaits saveSnapshot with try/catch instead of
  fire-and-forget to prevent race with Publish button
- Add tests: Pre-bulk-publish as non-translation, publishComplete: true fallthrough

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@seanchoi0
seanchoi0 requested a review from honstar July 24, 2026 08:09
Comment thread io/studio/src/bulk-publish/snapshot.js Outdated
Comment thread io/studio/src/bulk-publish/snapshot.js Outdated
Comment thread io/studio/src/bulk-publish/bulk-publish-worker.js Outdated
…shotError in final update

- Wrap recordSnapshot batch callback in try/catch so 500/network errors
  from getFragmentByPath or findNonTranslationVersion are captured as
  per-fragment failures instead of aborting the whole batch
- Track snapshotError across worker branches and use it in the final
  updateProject call instead of lastError: '' so SAVE_SNAPSHOT warnings
  are not silently discarded after publish completes

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@seanchoi0
seanchoi0 requested a review from honstar July 24, 2026 17:35
Comment thread io/studio/src/bulk-publish/snapshot.js Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Analogous to the fix applied to recordSnapshot where a single failure would reject the whole batch of fragments, please wrap this in a try/catch as well.

@seanchoi0 seanchoi0 Jul 27, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed — applied the same { entries, failures } pattern as recordSnapshot. Each fragment callback is now wrapped in try/catch so a single failure returns { path, error } instead of aborting the whole batch. createSnapshot now returns { entries, failures } and the worker accumulates any failures as a CREATE_SNAPSHOT: prefix in snapshotError, surfaced in lastError the same way SAVE_SNAPSHOT: failures are.

@seanchoi0
seanchoi0 requested a review from honstar July 27, 2026 23:44
…{ entries, failures }

Single-fragment failure in createSnapshot's processBatchWithConcurrency callback
would previously abort the entire batch. Apply the same { entries, failures } pattern
already used by recordSnapshot so partial failures are collected per-fragment without
stopping other paths. Worker accumulates CREATE_SNAPSHOT errors into snapshotError
alongside SAVE_SNAPSHOT errors; snapshot-action updated to match new return shape.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@honstar

honstar commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Please resolve conflicts.

- Keep snapshot helper functions (hasPendingSnapshot, addPendingMarker,
  removePendingMarker) from project.js import; remove local duplicates
- Merge updateProject try/catch from main with snapshotError from branch
- Import both saveSnapshot and resetToDraft in bulk-publish-store.test.js
Store.bulkPublishProjects.inEdit.set(new FragmentStore(new Fragment(raw)));
this.hasChanges = false;
showToast('Project created successfully.', 'positive');
const { saveSnapshot } = await import('./bulk-publish-store.js');

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Duplicated with the identical block at line 590 (same dynamic import + try/catch around saveSnapshot({...}), only project and the error message differ).
Maybe we can extract into a private method (#recordSnapshotAfterSave(project, context)) and call it from both places.

}
});

const failures = results.filter((r) => r?.error);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

revertSnapshot only walks Object.entries(snapshot.fragments)
A fragment that failed during recordSnapshot (line 183) is never added to snap.fragments, so it's absent from entries here too, it ends up in neither failures nor skipped, with no trace at revert time. Consider having recordSnapshot persist failed paths alongside the snapshot (or have the caller track them) so revertSnapshot/the UI can surface "N fragments have no revert target" instead of silently skipping them.


Take the highest `mas-js-v*` tag as the current version. Then read `web-components/package.json` and compare:

- If `package.json` is **behind** the latest release tag, it drifted (a previous bump commit was never committed/pushed). Warn the user, and treat the release tag — not `package.json` — as the baseline for choosing the next version.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

please do not revert this section. I guess this file is not supposed to be changed in this PR.


async function findNonTranslationVersion(odinEndpoint, fragmentId, authToken) {
const versions = await fetchVersionHistory(odinEndpoint, fragmentId, authToken);
const found = versions.find((v) => !isTranslationVersion(v));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

.find takes the first non-translation entry, so the revert target assumes Odin returns /versions newest-first. If that order isn't guaranteed we could revert to an older version — worth pinning with an explicit sort or a comment noting the assumption.

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.

7 participants