Skip to content

fix(tracker): keep sub-issue parent info in sync when an issue tree is moved - #11074

Open
MichaelUray wants to merge 2 commits into
hcengineering:developfrom
MichaelUray:fix/moved-subissue-parent
Open

MichaelUray wants to merge 2 commits into
hcengineering:developfrom
MichaelUray:fix/moved-subissue-parent

Conversation

@MichaelUray

Copy link
Copy Markdown
Contributor

Fixes #5714

Problem

Sub-issues store a denormalised copy of their ancestors (parents: id, title, identifier, space). #5816 renumbers the moved sub-issues, but their parents entries kept the old project's identifier and space at every depth, so breadcrumbs and parent links pointed to the old identifiers.

Two related defects in the same trigger:

  • Sub-issues were looked up with { 'parents.parentId': ... }. On the Postgres/CockroachDB adapter this becomes data#>>'{parents,parentId}', which does not match inside a JSON array, so the existing title propagation to sub-issues did not work there either.
  • When a sub-issue is moved without its parent (and detached in the same update), a refresh based on the stored chain could overwrite the re-parenting result.

Changes

  • OnIssueUpdate collects the issues of a batch whose title, identifier, space or attachedTo changed, walks their descendants via attachedTo ($in queries, indexed column), loads missing ancestors by _id, and rebuilds parents with a pure helper buildParentInfo by walking attachedTo upwards. Writes only when the chain differs; no queries for other updates; cycle-safe.
  • The re-parenting branch keeps its estimation/childInfo handling but no longer writes parents; updateSubIssues is removed.

Note: the TxRemoveDoc branch still queries 'childInfo.childId', which has the same Postgres limitation; left for a separate change.

Tests

sub-issue-parents.test.ts (8 tests). The fake storage only supports _id/attachedTo queries, so a nested-array lookup would fail the suite. Covers a three-level move, moving a sub-issue without its parent, re-parenting, rename and a no-op.

…s moved

Sub-issues store a denormalised copy of their ancestors (parents: title,
identifier, space). hcengineering#5816 already renumbers the moved sub-issues; this
change completes it by re-syncing their stored parent info.

The issue update trigger only patched the parent title on rename and the
chain on re-parenting, so after a move descendants kept the old project's
identifier and space at every depth. When a sub-issue was moved without
its parent (and detached from it in the same update) the stale chain could
also win over the re-parenting patch, leaving the old parent in the
chain. Sub-issues were in addition looked up via 'parents.parentId', a
field nested in a JSON array that the Postgres/CockroachDB adapter cannot
match.

The trigger now collects all issues of a batch whose title, identifier,
space or attachedTo changed, collects their descendants by walking the
attachedTo links, and rebuilds the parents info of these issues from
storage by walking attachedTo upwards. The result does not depend on the
order of the transactions in the batch, works on every storage backend,
and an issue is only updated when its chain actually changed. The
re-parenting branch keeps its estimation/childInfo handling but no longer
writes parents itself.

Fixes hcengineering#5714

Signed-off-by: Michael Uray <michaeluray@users.noreply.github.com>
Signed-off-by: Michael Uray <michaeluray@users.noreply.github.com>

This branch has not been deployed

No deployments
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.

Moving issue with sub-task to another project does not update sub-task project identifier

1 participant