fixed outcome issue when subclassing FlowSendHttpRequest #7407#7425
fixed outcome issue when subclassing FlowSendHttpRequest #7407#7425minaxi98 wants to merge 2 commits into
Conversation
Greptile SummaryThis PR fixes the missing outcome ports for subclasses of One design consideration worth noting: subclasses that wish to advertise different default status codes at design time would need to re-declare Confidence Score: 5/5This PR is safe to merge; the fix is narrowly scoped, correct, and well-covered by unit tests. No P0 or P1 issues found. Changes are additive (a new attribute, a new modifier, two DI registrations) and the existing No files require special attention.
|
| Filename | Overview |
|---|---|
| src/modules/Elsa.Http/Activities/FlowSendHttpRequest.cs | Adds [FlowNode] attribute to declare the four static outcome ports; the attribute is inheritable by default so subclasses pick it up automatically via GetCustomAttribute. |
| src/modules/Elsa.Http/Modifiers/FlowSendHttpRequestDescriptorModifier.cs | New IActivityDescriptorModifier that appends flow ports for each int in the ExpectedStatusCodes input's DefaultValue; handles deduplication, type guard, and null default value correctly. |
| src/modules/Elsa.Http/Features/HttpFeature.cs | Registers FlowSendHttpRequestDescriptorModifier as a scoped IActivityDescriptorModifier in the main workflow engine's DI container. |
| src/modules/Elsa.Http/ShellFeatures/HttpFeature.cs | Registers the same modifier in the shell (Elsa Studio backend) DI container; mirrors the main HttpFeature registration as expected for this pattern. |
| test/unit/Elsa.Http.UnitTests/Activities/FlowSendHttpRequestTests.cs | Comprehensive unit tests covering attribute inheritance, modifier port addition/deduplication, null/missing default value guards, and unrelated activity no-op; good regression coverage for #7407. |
Sequence Diagram
sequenceDiagram
participant AS as ActivityDescriber
participant FNA as FlowNodeAttribute<br/>(on FlowSendHttpRequest)
participant AD as ActivityDescriptor
participant MOD as FlowSendHttpRequestDescriptorModifier
participant STUDIO as Elsa Studio
AS->>FNA: GetCustomAttribute<FlowNodeAttribute>(inherit:true)
FNA-->>AS: ["Done","Unmatched status code","Failed to connect","Timeout"]
AS->>AD: Populate Ports (static flow ports)
AS->>AD: Populate Inputs (incl. ExpectedStatusCodes DefaultValue=[200])
AS->>MOD: Modify(descriptor)
MOD->>AD: ClrType.IsAssignableTo(FlowSendHttpRequest)?
AD-->>MOD: true (base or subclass)
MOD->>AD: Read ExpectedStatusCodes.DefaultValue
AD-->>MOD: [200]
MOD->>AD: Append Port("200", PortType.Flow)
AD-->>STUDIO: Descriptor with ports: Done, Unmatched status code, Failed to connect, Timeout, 200
Reviews (2): Last reviewed commit: "Update src/modules/Elsa.Http/Modifiers/F..." | Re-trigger Greptile
…odifier.cs Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
Purpose
Fixes subclasses of FlowSendHttpRequest showing only the "Done" outcome in the Studio designer by declaring flow ports on the base class so they are inherited automatically.
Scope
Select one primary concern:
Description
Problem
When subclassing FlowSendHttpRequest (e.g. class MyFlowSendHttpRequest : FlowSendHttpRequest), the Elsa Studio designer only showed a single "Done" outcome port. The expected ports — "Done", "Unmatched status code", "Failed to connect", "Timeout", and the configured status-code ports (e.g. "200") — were all missing.
The root cause is that FlowSendHttpRequest had no [FlowNode] attribute. ActivityDescriber.DescribeActivityAsync uses GetCustomAttribute(inherit: true) to build the Ports collection in the activity descriptor. Without the attribute on the base class, every subclass registered under its own type name received zero flow ports. The Studio hardcodes "Done" as a fallback, which is why only that one outcome appeared.
Solution
Solution
Added [FlowNode("Done", "Unmatched status code", "Failed to connect", "Timeout")] to FlowSendHttpRequest. Because FlowNodeAttribute has Inherited = true (the default) and ActivityDescriber calls GetCustomAttribute with inherit: true, all subclasses automatically inherit these ports without needing to redeclare the attribute.
Added FlowSendHttpRequestDescriptorModifier (IActivityDescriptorModifier) that detects any type assignable to FlowSendHttpRequest and appends flow ports for each status code present in the ExpectedStatusCodes input's default value. This ensures the default "200" port (and any other default codes a subclass declares) is visible at design time.
Registered the modifier in both HttpFeature and ShellFeatures/HttpFeature.
Verification
Steps:
Create a subclass of FlowSendHttpRequest in your project: public class MyFlowSendHttpRequest : FlowSendHttpRequest { }
Register it and open Elsa Studio.
Add the custom activity to a Flowchart workflow.
Expected outcome: The activity node shows "Done", "Unmatched status code", "Failed to connect", "Timeout", and "200" outcome ports — identical to the built-in FlowSendHttpRequest.
Screenshots / Recordings (if applicable)
Commit Convention
We recommend using conventional commit prefixes:
fix:– Bug fixes (behavior change)feat:– New featuresrefactor:– Code changes without behavior changedocs:– Documentation updateschore:– Maintenance, tooling, or dependency updatestest:– Test additions or modificationsClear commit messages make reviews easier and history more meaningful.
Checklist