Skip to content

fix: automated upload works for non-English sources and matches the manual upload; webhook dialog URL - #133

Merged
david-vaclavek merged 3 commits into
mainfrom
fix/automated-upload-keys
Nov 11, 2026
Merged

david-vaclavek merged 3 commits into
mainfrom
fix/automated-upload-keys

Conversation

@david-vaclavek

@david-vaclavek david-vaclavek commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Fixes the automation loop: save in Strapi → automated upload → Localazy → webhook → download. Found while setting it up on the same site as #131 (Czech source, English via Localazy AI). Three independent bugs stopped or corrupted it.

1. Automated upload never ran when the source language isn't English

The hooks looked up the default locale with locales.find() + isDefault. Strapi's i18n service returns plain locale rows without isDefault; only its admin API adds it. So the lookup always fell back to the plugin default en, and for any other source language every automated upload/deprecation stopped with Source locales do not match; the operation won't proceed. It now uses getDefaultLocaleCode(), as the manual upload does.

2. Automated upload/deprecation built different keys than the manual upload

Manual upload Automated upload / deprecation (≤ 1.7.1)
Blocks fields one key per text leaf (projectBlocksFields) the raw AST: story[0].type = paragraph, …children[1].bold = true, …url = https://… uploaded as source strings
Dynamic zone fields picked per component (getPickPathsWithComponents) dropped: getPickPaths never matches dynamic zone keys
Entries excluded from translation skipped uploaded anyway

The new getUploadKeysForEntries builds the keys for both paths. The hooks also skip excluded entries.

3. The webhook setup dialog suggested a dead URL

It pre-filled <server url>/api/localazy/public/transfer/download, but the plugin's public route is /localazy/public/transfer/download. Strapi answers the /api path with 405 (as it does for any unknown POST under /api), so a webhook saved with the suggestion never reached the plugin.

Tests

  • get-picked-flatten-keys-for-hook-entry.test.ts runs the real hook helper (plugin services and Strapi mocked as Strapi returns them: locale rows without isDefault) for create, update and delete. It asserts the keys equal the manual upload's: blocks text leaves only, dynamic zone and component fields included, no type/bold/url keys. Excluded entries are skipped. All 4 cases fail on 1.7.1.
  • transfer-round-trip.test.ts now uploads through getUploadKeysForEntries.
  • Whole suite: 29 suites / 278 tests. test:ts:back, test:ts:front, lint, format:check, build and verify pass locally.

Verified on a real Strapi 5.50 instance

Local mirror of the site, connected to its real Localazy project. Automated upload on create/update and deprecation on delete were enabled, and the webhook was registered through the dialog behind a temporary tunnel.

  • With 1.7.1, saving a new Czech session logged Source locales do not match and uploaded nothing.
  • With this branch, editing it uploaded exactly 5 keys: title, subtitle, location, and the two text leaves of the story split at a bold mark. A Localazy automation ("Imported new source key" → Localazy AI → review) translated them.
  • Localazy's signed project_published webhooks reached the plugin through the URL the dialog suggested, passed verification, and started incremental English-only downloads.
  • After approving the AI translations and publishing, the next webhook's incremental download created the English session: blocks rebuilt with the bold mark, glossary term applied. The site rendered it at /en/s/<slug>.
  • Deleting the session (all locales) ran the deprecation hook (delete hook result: {"success":true}), and its keys disappeared from the active key list in Localazy.

🤖 Generated with Claude Code

david-vaclavek and others added 3 commits November 11, 2026 16:45
…l upload

The create/update upload hook and the delete deprecation hook built their
keys differently from the manual upload:

- blocks fields were not projected to their text leaves, so saving an entry
  uploaded the raw AST (`type`, `bold`, `url`, … as source strings),
- `getPickPaths` instead of `getPickPathsWithComponents` dropped every
  dynamic zone field, so saving never uploaded dynamic zone content,
- entries excluded from translation were uploaded anyway.

Both paths now use one `getUploadKeysForEntries`, and the hooks skip
excluded entries.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The dialog suggested `<server url>/api/localazy/public/transfer/download`,
but the plugin's public route is `/localazy/public/transfer/download` (no
`/api` prefix). Strapi answers the `/api` path with 405, so a webhook saved
with the suggested URL never reached the plugin.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The hooks looked for the default locale with `locales.find()` +
`isDefault`, but Strapi's i18n service returns plain locale rows without
`isDefault` (only its admin API adds it). The lookup always fell back to
the plugin default `en`, so for any project with another source language
every automated upload and deprecation stopped with "Source locales do
not match". Use `getDefaultLocaleCode()`, as the manual upload does.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@david-vaclavek david-vaclavek changed the title fix: automated upload and deprecation send the same keys as the manual upload (blocks, dynamic zones, exclusions) fix: automated upload works for non-English sources and matches the manual upload; webhook dialog URL Nov 11, 2026
@david-vaclavek
david-vaclavek merged commit e350b79 into main Nov 11, 2026
6 checks passed
@david-vaclavek
david-vaclavek deleted the fix/automated-upload-keys branch November 11, 2026 16:19
@localazy-bot localazy-bot Bot mentioned this pull request Nov 11, 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.

2 participants