Skip to content

Conversation

@AndyButland
Copy link
Contributor

@AndyButland AndyButland commented Aug 18, 2025

Prerequisites

  • I have added steps to test this contribution in the description below

Resolves an issue found in internal testing:

I stumbled upon a small bug in the Dictionary Item server event. It looks like it emits a "Created" event when the item is updated.

Description

On investigating the issue here is due to dictionary items being a bit of a special case. They are entities in the sense of implementing IEntity that gives them a create and updated date, but we don't store these in the database. Hence it doesn't really matter what they are set to apart from in the logic with have in ServerEventSender, where we compare the two dates to determine whether to emit a Created or Updated event.

Note that we don't have access to using whether or not the entity has an identity, as these events fire after persistence when the identity is known for both creates and updates.

So I've added code into the update dictionary item event to set the dates explicitly to something that can be used to determine that this is an update not a create. This means when the base UpdatingEntity() method is called, the dates won't be initialized to the same value.

Testing

Put a break point in ServerEventSender.NotifySavedAsync and verify that the emitted event has the correct EventType for created and updated dictionary items.

Merge and Release

Note the TODO added that should be actioned when this is merged into the v17/feature/utc-system-dates branch.

…ary items to allow distinguishing between created and update for server events.
Copilot AI review requested due to automatic review settings August 18, 2025 06:01
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes an issue where dictionary item server events incorrectly emit "Created" events when items are updated. The fix ensures that create and update dates are properly set to distinguish between creation and update operations for server event emission.

  • Adds explicit date setting logic to the UpdateAsync method in DictionaryItemService
  • Sets CreateDate to DateTime.MinValue and UpdateDate to DateTime.Now when dates are default values
  • Includes a TODO comment for future UTC alignment in V17

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Copy link
Contributor

@kjac kjac left a comment

Choose a reason for hiding this comment

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

Works like a charm 💪

@kjac kjac merged commit a5f9bba into main Aug 18, 2025
26 checks passed
@kjac kjac deleted the v16/bugfix/emity-correct-dictionary-item-server-events branch August 18, 2025 09:42
@AndyButland AndyButland changed the title Ensure appropriate create and update dates are set on updated dictionary items to allow distinguishing between created and update for server events. Ensure appropriate create and update dates are set on updated dictionary items to allow distinguishing between created and update for server events Aug 20, 2025
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.

3 participants