Skip to content

[COMMS-1067] Pass only cause objects to the journal service - #26489

Closed
akabiru wants to merge 2 commits into
implementation/comms-1067-journal-admin-label-deletionfrom
implementation/comms-1067-typed-journal-causes
Closed

akabiru wants to merge 2 commits into
implementation/comms-1067-journal-admin-label-deletionfrom
implementation/comms-1067-typed-journal-causes

Conversation

@akabiru

@akabiru akabiru commented Oct 30, 2026 •

Copy link
Copy Markdown
Member

Ticket

https://community.openproject.org/wp/COMMS-1067

What are you trying to accomplish?

The journal service now receives only cause objects. Merging a label deletion into the previous journal's cause (#26191) needed a try, because one caller still handed the service a plain Hash: the "Read-only attributes written" cause set when an admin writes created_at or the author through the API. That cause is now its own class, so the service calls merge_into directly, and a caller passing anything else fails loudly instead of silently never merging.

The same check also never fired for an admin who set only the author, since attribute changes are keyed by column (author_id), not association name. It now does.

What approach did you choose and why?

Fixing the one producer keeps the service's contract honest without adding a coercion layer for a case only tests used. Saved journal data is unchanged: a cause object serialises to the same JSON as the Hash did, and comparing a stored cause Hash with a cause object still matches. The acts_as_journalized specs that passed bare strings or Hashes as causes now pass real cause types.

AI involvement

Collaborative – AI generated a substantial part of the code; I reviewed and understand every line.

Merge checklist

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

The readonly-attribute cause was the one plain Hash reaching the service, so
cause merging had to guard with try. With every cause a CauseOfChange::Base,
the service calls merge_into directly and an untyped cause fails loudly.
Attribute changes are keyed by column, so the readonly check never matched
"author" and an admin setting only the author got no cause on the journal.
@akabiru
akabiru added this pull request to stack #26490 October 30, 2026 13:16
@akabiru akabiru changed the title implementation/comms 1067 typed journal causes [COMMS-1067] Pass only cause objects to the journal service Oct 30, 2026
@akabiru akabiru self-assigned this Oct 30, 2026
@github-actions github-actions Bot added the ai: Collaborative 💻 AI generated a substantial part of the code; A human reviewed and understands every line. label Oct 30, 2026
@akabiru
akabiru removed this pull request from stack #26490 October 30, 2026 14:52
@akabiru akabiru closed this Oct 30, 2026
@akabiru
akabiru deleted the implementation/comms-1067-typed-journal-causes branch October 30, 2026 14:53
@github-actions github-actions Bot locked and limited conversation to collaborators Oct 30, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

ai: Collaborative 💻 AI generated a substantial part of the code; A human reviewed and understands every line.

Development

Successfully merging this pull request may close these issues.

1 participant