Skip to content

fix: Correctly handle semantic ID counter on project copy#23121

Merged
thykel merged 2 commits intodevfrom
fix/project-copy-counter-bug
May 8, 2026
Merged

fix: Correctly handle semantic ID counter on project copy#23121
thykel merged 2 commits intodevfrom
fix/project-copy-counter-bug

Conversation

@thykel
Copy link
Copy Markdown
Contributor

@thykel thykel commented May 7, 2026

Ticket

https://community.openproject.org/projects/communicator-stream/work_packages/74750

What are you trying to accomplish?

Fix the issue described in the ticket.

The root cause is that when wp_sequence_counter had non-zero value (= the project has had semantic IDs enabled and there is at least one WP), the copy mechanism attempted to copy it over to the new project, because it detected a difference from the default value (zero).

However, since wp_sequence_counter isn't declared as writable (since it's not specified in Projects::BaseContract), it trips up our own validation and the error propagates into the UI as the message visible in the parent ticket.

What approach did you choose and why?

Let's just completely ignore that column during the copy process. The new project will get it initialized to 0, and then the counter gets organically gradually increased by the (optional) copying of all WPs from the old project.

Merge checklist

  • Added/updated tests
  • Added/updated documentation in Lookbook (patterns, previews, etc)
  • Tested major browsers (Chrome, Firefox, Edge, ...)

@thykel
Copy link
Copy Markdown
Contributor Author

thykel commented May 7, 2026

Sidenote: This made me realize that if we copy a project along with its WPs, the new semantic numbering may not match the old one. This can happen due to variety of reasons:

  • Gaps induced by package moves: If we copy OLDPROJ to NEWPROJ and OLDPROJ-2 has been previously moved (leaving a "gap" that resolves to something like OTHERPROJ-10), NEWPROJ-2 will now point to a copy of OLDPROJ-3 and all subsequent IDs will be shifted by 1.
  • Ordering change induced by parent changes: If we copy OLDPROJ to NEWPROJ and OLDPROJ-1 has previously changed its parent to OLDPROJ-3, the new numbering will be different, as the sequence will be assigned in order of tree depth.
    • Example old state: OLDPROJ-3 (id=100, top-level parent) = OLDPROJ-1 (id=50, child) + OLDPROJ-2 (id=75, child)
    • Example new state: NEWPROJ-1 (was OLDPROJ-3) = NEWPROJ-2 (was OLDPROJ-1) + NEWPROJ-3 (was OLDPROJ-2)
  • ...maybe some more.

Let's also decide how much we care about this.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 8, 2026

Deploying openproject with PullPreview

Field Value
Latest commit 53a5576
Job deploy
Status ✅ Deploy successful
Preview URL https://pr-23121-project-copy-coun-ip-178-105-77-88.my.opf.run:443

View logs

Copy link
Copy Markdown
Member

@akabiru akabiru left a comment

Choose a reason for hiding this comment

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

:shipit:

@thykel thykel merged commit 3ff2481 into dev May 8, 2026
19 of 21 checks passed
@thykel thykel deleted the fix/project-copy-counter-bug branch May 8, 2026 12:31
@github-actions github-actions Bot locked and limited conversation to collaborators May 8, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants