Skip to content

Fix PUT /page/:pageid Column Generation Behavior#503

Merged
cubap merged 1 commit intodevelopmentfrom
502-lines-columns
May 1, 2026
Merged

Fix PUT /page/:pageid Column Generation Behavior#503
cubap merged 1 commit intodevelopmentfrom
502-lines-columns

Conversation

@thehabes
Copy link
Copy Markdown
Member

@thehabes thehabes commented May 1, 2026

Closes #502.

PUT /page/:pageId was creating one new column per new line item. This was observed when the "Detect Lines" prompts submit all lines in a single PUT, which produced N single-line columns whose order had no relationship to reading order — breaking line-by-line navigation.

Change

Removed the auto-column-create branch in the updatedItemsList loop and unwrapped the surrounding else so the split-into-existing-column logic runs unconditionally.

Preserved behavior

  • Existing-column line-id remapping when RERUM versions a changed line.
  • Splitting a RERUM-tracked line: numeric date-id children are appended to the parent's column.
  • Line deletion: dropped lines leave their column; empty columns are deleted.
  • Explicit column creation via POST /page/:pageId/column is unchanged.

Side effect

pageColumnsUpdate.find(...) is now pageColumnsUpdate?.find(...). The new block runs for every updatedItemsList entry, so the variable can legitimately be null (column-less page). Closes a latent null-deref on column-less pages whose lines get RERUM-versioned by a PUT.

Manual testing

# Scenario Starting state Request Result
1 Bulk-create on a page with one column 1 line, 1 column (A) echo existing line + 2 brand-new lines ✅ 3 items, Column A unchanged, no new columns
2 Single-column split continued from 1 parent line (body change) + 2 numeric date-id children + 2 preserved lines ✅ 5 items; Column A tracked new parent URI and gained both split children
3 Line deletion from a column continued from 2 4 items; one column-tracked child omitted ✅ Column dropped the omitted child; tracked new URIs for the rest
4 No-op PUT (re-versioning guard) reset: 1 line, 1 column same id + same target, no body ✅ URI unchanged — hasAnnotationChanges correctly skipped re-versioning
5 Multi-column split with brand-new line in same PUT reset: 2 lines, 2 columns (A, B) A (body edit) + numeric child for A; B (body edit) + numeric child for B; 1 brand-new line ✅ Both columns tracked their new parent URI and gained their own child only; brand-new line created no third column
6 Bulk-create on a column-less page different page: 1 line, 0 columns echo existing line + 5 brand-new lines ✅ 6 items in submission order; columns still null; existing URI preserved (target unchanged); the new pageColumnsUpdate?.find(...) null-safety branch exercised

@thehabes thehabes self-assigned this May 1, 2026
@thehabes thehabes marked this pull request as ready for review May 1, 2026 19:07
@thehabes thehabes requested a review from cubap as a code owner May 1, 2026 19:07
@thehabes thehabes changed the title Update PUT /page/:pageid Column Generation Behavior Fix PUT /page/:pageid Column Generation Behavior May 1, 2026
@thehabes thehabes linked an issue May 1, 2026 that may be closed by this pull request
Copy link
Copy Markdown
Member

@cubap cubap left a comment

Choose a reason for hiding this comment

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

worked as tested

@cubap cubap merged commit 32dcfb2 into development May 1, 2026
4 checks passed
@cubap cubap deleted the 502-lines-columns branch May 1, 2026 19:45
@thehabes thehabes mentioned this pull request May 5, 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.

Investigate 'one column per line' Behavior

2 participants