[codex] Show workflow validation API errors#899
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR improves how Elsa Studio surfaces backend workflow validation errors by parsing plain JSON 400 Bad Request responses into ValidationErrors, allowing the existing editor snackbar to display actionable server messages (e.g., duplicate HTTP endpoint validation).
Changes:
- Add
ApiException.GetValidationErrors()that can extract messages from plain JSON error payloads (and delegates to the existingValidationApiExceptionpath when applicable). - Update workflow definition save/retract/create service methods to catch
ApiExceptionfor HTTP 400 and convert the response intoValidationErrors. - Add regression tests covering extraction of
errors.generalErrorsand fallback tomessage.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/modules/Elsa.Studio.Workflows.Tests/ValidationApiExceptionExtensionsTests.cs | Adds regression tests for parsing validation messages from plain JSON ApiException content. |
| src/modules/Elsa.Studio.Workflows.Core/Domain/Services/WorkflowDefinitionService.cs | Converts 400 ApiExceptions into ValidationErrors for create/retract flows. |
| src/modules/Elsa.Studio.Workflows.Core/Domain/Services/WorkflowDefinitionHistoryService.cs | Converts 400 ApiExceptions into ValidationErrors for history retract flow. |
| src/modules/Elsa.Studio.Workflows.Core/Domain/Services/WorkflowDefinitionEditorService.cs | Converts 400 ApiExceptions into ValidationErrors for editor save/retract flows. |
| src/modules/Elsa.Studio.Workflows.Core/Domain/Extensions/ValidationApiExceptionExtensions.cs | Adds JSON parsing for ApiException bodies to extract error messages into ValidationErrors. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
ValidationErrors.errors.generalErrorsso the existing workflow editor snackbar shows the actionable server message.Why
Elsa Core already returns useful validation details for duplicate HTTP trigger endpoints, but Studio could surface the generic Refit
ApiExceptiontext when the response is not materialized asValidationApiException. The workflow editor already displaysValidationErrors; this change makes the service layer feed it the useful API messages.Fixes elsa-workflows/elsa-core#7678 from the Studio UI side.
Validation
dotnet test src/modules/Elsa.Studio.Workflows.Tests/Elsa.Studio.Workflows.Tests.csprojdotnet test src/modules/Elsa.Studio.Workflows.Tests/Elsa.Studio.Workflows.Tests.csproj --no-restoreNotes
A full browser repro was not run because it requires a configured Elsa backend with conflicting HTTP-trigger workflow definitions. The behavior is covered at the service conversion layer that feeds the existing editor snackbar.