Skip to content

fix(content): correctness fixes for push, merge, and delete#2721

Open
catalan-adobe wants to merge 1 commit intoadobe:mainfrom
catalan-adobe:fix/content-cmd-correctness
Open

fix(content): correctness fixes for push, merge, and delete#2721
catalan-adobe wants to merge 1 commit intoadobe:mainfrom
catalan-adobe:fix/content-cmd-correctness

Conversation

@catalan-adobe
Copy link
Copy Markdown

Summary

Five correctness fixes to the aem content subcommand, all in src/content/. The load-bearing one was discovered while writing tests for the others.

push.cmd.js

  • --path exact-or-trailing-slash matching. --path /blog no longer matches /blog2/post.html. Mirrors the existing pattern in add.cmd.js (filepathInContentAddScope).
  • Held-back synced ref under --path. When a --path filter excludes other ahead changes, the synced ref is no longer advanced to HEAD; the user is told to re-run without --path to fully sync. Otherwise the next push computes an empty diff and silently drops the unfiltered changes.
  • processQueue mutation gotcha. processQueue consumes its input array via shift(), so the prior putTargets.every(p => successfullyPushed.has(p)) and deleted.every(p => successfullyDeleted.has(p)) checks were vacuously true and the synced ref was advanced on every push — even when uploads or deletes failed. Now uses the error counts returned by _uploadFiles / _deleteFiles. The methods also defensively copy their input internally.

merge.cmd.js

  • Token directory. getValidToken now receives the project root (this._dir) instead of contentDir. The cached login is reused across content subcommands, and .hlx/.da-token.json is no longer written inside the inner content git repo.

da-api.js

  • deleteSource error shape. Now throws on non-2xx (matching putSource) and treats 404 as success (idempotent delete). Previously a 5xx returned false silently, and _deleteFiles didn't check the return value, so server failures were logged as ✓ deleted.

Test plan

  • node_modules/.bin/mocha test/content/ test/content-metadata-html.test.js — 188 passing
  • npm test (full suite) — 479 passing, 3 environmental failures in test/git-utils.test.js (isomorphic-git can't resolve tags through a worktree's gitdir: indirection; reproduces on unmodified main from any worktree)
  • eslint . clean
  • New regression tests:
    • da-api.test.js: delete throws on 5xx; delete treats 404 as success
    • merge.cmd.test.js: project root passed to getValidToken
    • push.cmd.test.js: --path /blog doesn't bleed to /blog2; synced ref held back under --path; synced ref advanced when --path covers all ahead changes; synced ref held back when a delete fails on the server

🤖 Generated with Claude Code

* push: --path now uses exact-or-trailing-slash matching, so
  `--path /blog` no longer matches `/blog2/post.html`.
* push: do not advance refs/da/synced when a --path filter
  excludes other ahead changes — those would otherwise be silently
  considered already synced on the next run.
* push: rely on the error counts returned by _uploadFiles and
  _deleteFiles instead of re-reading the input arrays. processQueue
  consumes its input via shift(), so putTargets.every(...) and
  deleted.every(...) were vacuously true and the synced ref was
  advanced on every push even when uploads or deletes failed.
* merge: pass the project root (not content/) to getValidToken so
  the cached login is reused across content subcommands and
  .hlx/.da-token.json is not written inside the content repo.
* da-api: deleteSource throws on non-2xx (matching putSource) and
  treats 404 as success (idempotent delete).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.

1 participant