Commit graph

9 commits

Author SHA1 Message Date
Copilot 5b336254b8
fix: restore HashSet-backed Fork completion state on resumed workflows (#7431)
* Initial plan

* fix: handle restored fork completed state as list

Agent-Logs-Url: https://github.com/elsa-workflows/elsa-core/sessions/dbed3cbb-8d9c-4493-b692-ee24b6c90c7d

Co-authored-by: sfmskywalker <938393+sfmskywalker@users.noreply.github.com>

* test: avoid reflection in fork regression coverage

Agent-Logs-Url: https://github.com/elsa-workflows/elsa-core/sessions/dbed3cbb-8d9c-4493-b692-ee24b6c90c7d

Co-authored-by: sfmskywalker <938393+sfmskywalker@users.noreply.github.com>

* fix: preserve hashset state for resumed fork completion

Agent-Logs-Url: https://github.com/elsa-workflows/elsa-core/sessions/d1bdb2e8-916c-45a0-9508-3e06052d806a

Co-authored-by: sfmskywalker <938393+sfmskywalker@users.noreply.github.com>

* fix: guard reflected collection add lookup

Agent-Logs-Url: https://github.com/elsa-workflows/elsa-core/sessions/d1bdb2e8-916c-45a0-9508-3e06052d806a

Co-authored-by: sfmskywalker <938393+sfmskywalker@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: sfmskywalker <938393+sfmskywalker@users.noreply.github.com>
2026-05-02 11:23:17 +02:00
Sipke Schoorstra 1b8083a5c6
Update multitenancy logic and improve Result handling: (#7281)
* Update multitenancy logic and improve `Result` handling:

- Introduce `TenantsOptions` with `IsEnabled` flag to conditionally apply tenant-specific logic.
- Refactor `Result` class to support strongly-typed operations and async handlers.
- Implement tenant filters respecting multitenancy enablement.
- Enhance error logging for workflow definition addition, upgrading error handling.
- Refactor tests and storage drivers to use `IsSuccess` from `Result`.

* Update src/modules/Elsa.Workflows.Runtime/Services/DefaultWorkflowDefinitionStorePopulator.cs

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Add exception handling when accessing `Value` on failed results; introduce `ValueOrDefault` property for better null support.

* Add `ThrowIfFailure` method to handle exceptions in `Result` model and use it in `DefaultWorkflowRegistry` to ensure operation success.

* Normalize tenant ID handling by using `NormalizeTenantId()` in `DefaultWorkflowDefinitionStorePopulator`.

* Normalize tenant ID usage in unit tests by returning `tenantId.NormalizeTenantId()` in `DefaultWorkflowDefinitionStorePopulatorTests`.

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2026-02-11 10:11:12 +01:00
bobhauser 59bd21f899
Fix ObjectConverter.ConvertTo to avoid using sourceTypeConverter.IsValid (#6972)
* Fix ObjectConverter.ConvertTo to avoid using sourceTypeConverter.IsValid

* Update test/unit/Elsa.Workflows.Core.UnitTests/ObjectConversion/PersonTypeConverter.cs

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

---------

Co-authored-by: Bob Hauser <rhauser@kinaxis.com>
Co-authored-by: Sipke Schoorstra <sipkeschoorstra@outlook.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-10-16 13:51:37 +02:00
Sipke Schoorstra d72c4974d2
Refactor ObjectConverter to improve readability and add backward-compatible default value handling in non-strict mode. (#6852)
* Refactor `ObjectConverter` to improve readability and add backward-compatible default value handling in non-strict mode.

* Add `StrictMode` option to `ObjectConverterOptions` and update related tests

Introduced a `StrictMode` option to `ObjectConverterOptions` to control strict type conversion behavior. Updated the `ObjectConverter` logic to utilize this new option and refactored unit tests to include `ObjectConverterOptions` where necessary, ensuring comprehensive test coverage for strict and non-strict mode scenarios.

* Fix ObjectConverter default value handling and update unit tests

Standardize usage of `targetType` for default values in `ObjectConverter`. Refactor and consolidate unit tests to improve coverage and clarity, addressing various conversion and exception scenarios.
2025-08-11 08:50:45 +02:00
Sipke Schoorstra 612fd26388
Enable strict mode for ObjectConverter in unit tests
Set ObjectConverter.StrictMode to true in the test constructor to enforce stricter conversion rules during tests. This ensures better reliability and consistency in test coverage.
2025-04-10 19:57:39 +02:00
Sipke Schoorstra 952cbb4edc
Add strict type checking for variable parsing (#6536)
* Add strict type checking for variable parsing

Introduced a `StrictMode` flag for variables, enforcing stricter type validation during parsing and conversions. Updated related methods and tests to reflect the stricter parsing behavior, ensuring consistent type compatibility and error handling.

* Refactor StrictMode handling and improve ObjectConverter logic

Moved StrictMode flag from Variable to ObjectConverter for better cohesion and updated related references. Additionally, removed unused parameters and simplified ObjectConverterOptions to streamline configuration and maintain consistency across the codebase.

* Refactor type conversion logic and update logging defaults

Improve type conversion reliability by introducing `TryConvertValue` and refining exception handling. Update JSON scenarios to use "Inherit" as the default for log persistence modes, ensuring consistency across configurations.

* Refactor exception handling in ObjectConverter.

Introduce a helper method `ReturnOrThrow` to streamline and centralize exception handling logic. This change also adds support for non-strict mode, allowing value fallback instead of throwing exceptions when enabled.

* Add numeric type checks and improve type conversion handling

Introduce `IsNumericType` extension method to identify numeric types. Enhance type conversion logic in `ObjectConverter` to handle numeric, boolean, and string types more accurately. Update variable deserialization workflows to handle conversion failures gracefully.

* Set a default comment for ObjectConverter.StrictMode assignment

Added a comment clarifying that StrictMode is set to its default value. This improves code readability and helps maintainers understand the intent.

* Fix formatting inconsistencies and improve code clarity

Removed redundant whitespace and adjusted formatting to align with coding standards. These changes enhance the readability and maintainability of the code without altering functionality.

* Fix typo in Program.cs variable comment

Corrected a minor issue in the comment for `identityTokenSection` to remove the unnecessary "Modify" text. This change improves code readability and removes potential confusion for developers.

* Simplify imports in ModifyVariableHandler.cs

Removed unused `Microsoft.Extensions.Options` and `Elsa.Workflows.Options` imports to clean up dependencies and improve maintainability. This change reduces clutter without affecting the existing functionality.
2025-03-31 18:11:14 +02:00
Sipke Schoorstra 8e9d5e356e
Handle conversion of enumerables to arrays in ObjectConverter (#6508)
* Handle conversion of enumerables to arrays in ObjectConverter

Added functionality to convert enumerables to arrays when the target type is an array. The implementation ensures each item is properly cast to the target array's element type and then added to the resulting array.

* Add unit test for converting object array to double array

This commit introduces a new test ensuring the proper conversion of an object array of doubles to a double array. It verifies both the validity of the conversion and that the result is not null.
2025-03-18 16:09:49 +01:00
Sipke Schoorstra 0560d11432 Improve JSON array conversion in ObjectConverter
Refactored ObjectConverter to handle JSON array conversions more robustly, including support for arrays of complex types. Added a `Person` class for unit testing and updated tests to validate the new functionality. Included necessary project reference updates to ensure proper functionality.
2025-01-29 10:50:42 +01:00
Sipke Schoorstra efd114944c Refactor and enhance JavaScript and object conversions.
Replaced InputProxy with alternative implementations, adding flexibility to handle inputs. Introduced a JsonElementConverter to deepen JavaScript and JSON element integration. Enhanced testing and object conversion logic, improving type handling and support for complex JSON scenarios.
2025-01-14 23:16:29 +01:00