Skip to content

[Bug] Error when using Webtools URL alias with Draft & Publish enabledΒ #335

@sarahanzo

Description

@sarahanzo

Addon

No specific addon – This bug report is related to Webtools Core

Describe the bug

When enabling Draft & Publish on a collection that uses Webtools URL aliases, the plugin throws an SQL error during bulk URL generation or alias reordering.

The error only appears after activating Draft & Publish, because Strapi duplicates entries with the same document_id (draft + published versions).

Error Log:

error: UPDATE `tests_url_alias_lnk` as a, (
  select `id`, row_number() over (partition by `test_id` order by `url_alias_ord`) as src_order
  from `tests_url_alias_lnk`
  where `test_id` = 25
) AS b
SET `url_alias_ord` = b.src_order
WHERE b.id = a.id
Record has changed since last read in table 'tests_url_alias_lnk'

Database Before Enabling Draft & Publish

tests
id | document_id | title | slug | published_at
22 | f6y...       | Test 1 | test-1 | 2025-10-09
23 | sz5...       | Test 2 | test-2 | 2025-10-09

tests_url_alias_lnk
id | test_id | url_alias_id | url_alias_ord
170 | 22 | 94 | 1
172 | 23 | 95 | 1

After Enabling Draft & Publish

tests
id | document_id | title | slug | published_at
22 | f6y... | Test 1 | test-1 | 2025-10-09
24 | f6y... | Test 1 | test-1 | NULL
23 | sz5... | Test 2 | test-2 | 2025-10-09
25 | sz5... | Test 2 | test-2 | NULL

tests_url_alias_lnk
id | test_id | url_alias_id | url_alias_ord
170 | 22 | 94 | 1
172 | 23 | 95 | 1
174 | 24 | 94 | 1
175 | 25 | 95 | 1

Steps to reproduce the behavior

  1. Create a new collection type (e.g. test) with fields:
title (text)
slug (UID, from title)
parent_page (relation)

  1. Configure Webtools URL pattern: [parent_page.slug]/[slug]
  2. Create two records
  3. Run Bulk Generate β†’ works fine.
  4. Enable Draft & Publish on the same collection.
  5. Run Bulk Generate again β†’ error appears.

Expected behavior

The plugin should either ignore draft entries when generating aliases, or correctly handle multiple records with the same document_id.

Screenshots

No response

Code snippets

Node.js version

v20.19.5

Package manager

NPM

Strapi version

5.27.0

Plugin version

1.7.0

Database

MariaDB

Operating system

Mac OS 14.3

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions