Skip to content

Preserve metadata for unknown activities#7323

Merged
sfmskywalker merged 4 commits intorelease/3.6.0from
issue/elsa-studio-765
Feb 25, 2026
Merged

Preserve metadata for unknown activities#7323
sfmskywalker merged 4 commits intorelease/3.6.0from
issue/elsa-studio-765

Conversation

@sfmskywalker
Copy link
Member

Summary

  • Extract and retain the metadata payload when deserializing an activity whose type cannot be resolved.
  • Prevent loss of workflow designer metadata (e.g., layout, annotations) to improve round-tripping and diagnostics.

Why

  • Previously, unknown activities were converted to a placeholder without carrying over metadata, causing UI/authoring context to be lost.
  • Retaining metadata ensures the designer and tooling can still position and represent the placeholder accurately.

How

  • When the activity type is not found, read the "metadata" object from the input JSON and assign it to the placeholder activity’s metadata bag.

How to Test

  1. Create or load a workflow JSON with an activity type that is not available/resolvable.
  2. Ensure the JSON contains a "metadata" object on that activity (e.g., coordinates, notes).
  3. Deserialize the workflow using the standard workflow deserialization pipeline.
  4. Verify that the placeholder/“not found” activity now includes the original metadata values.
  5. Re-serialize and confirm the metadata is preserved.
  6. In the UI (if applicable), confirm layout/annotations for the unknown activity are maintained.
    • Include before/after screenshots or GIFs if there are visible UI changes.

Breaking Changes

  • None identified.

Review Focus

  • Confirm the metadata deserialization is robust and tolerant of varying metadata shapes (nulls, primitives, nested objects).
  • Validate performance impact is negligible for large metadata objects.
  • Ensure no unintended overwrites occur if a placeholder already carries metadata.
  • Verify error handling when "metadata" is missing or malformed (should be a no-op).

Relates to elsa-studio-765

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Feb 25, 2026

Greptile Summary

This PR correctly preserves metadata for unknown activities during deserialization. The implementation addresses the issue raised in elsa-studio-765 where workflow designer metadata (layout, annotations) was lost when an activity type couldn't be resolved.

Key changes:

  • Extracts metadata from doc.RootElement when creating a NotFoundActivity placeholder
  • Assigns extracted metadata before setting display text/description, ensuring these system properties always reflect the current state
  • Correctly handles the distinction between outer wrapper JSON and inner originalActivityJson

The developer's responses to previous thread comments demonstrate understanding of the code flow. The metadata extraction reads from the correct source (doc.RootElement for NotFoundActivity wrappers vs activityRoot for inner activity JSON), and repositioning the SetDisplayText/SetDescription calls after metadata assignment is the right approach.

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • The implementation is focused and correct. It preserves metadata for unknown activities without affecting normal activity deserialization. The developer has addressed previous review comments appropriately by repositioning metadata-modifying calls after the metadata assignment. The existing test coverage validates the expected behavior.
  • No files require special attention

Important Files Changed

Filename Overview
src/modules/Elsa.Workflows.Core/Serialization/Converters/ActivityJsonConverter.cs Adds metadata preservation when deserializing unknown activities - implementation is correct and addresses the previous thread concerns

Last reviewed commit: daa0f57

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

1 file reviewed, 3 comments

Edit Code Review Agent Settings | Greptile

@sfmskywalker sfmskywalker requested a review from Copilot February 25, 2026 18:05
@sfmskywalker
Copy link
Member Author

@greptile please do another round of review.

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 addresses the loss of designer/UI metadata when deserializing activities whose types cannot be resolved. Previously, when an unknown activity was converted to a NotFoundActivity placeholder, its metadata (containing layout coordinates, annotations, etc.) was lost, causing issues with workflow designer round-tripping.

Changes:

  • Extract and preserve metadata from unknown activities during deserialization
  • Assign metadata to NotFoundActivity before setting display text/description to ensure proper ordering
  • Add explanatory comments documenting the metadata preservation logic

…ityJsonConverter.cs

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@sfmskywalker sfmskywalker merged commit 7e2829d into release/3.6.0 Feb 25, 2026
2 checks passed
@sfmskywalker sfmskywalker deleted the issue/elsa-studio-765 branch February 25, 2026 19:03
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