Skip to content

Deterministic ZIP export and 404 test coverage for consumers endpoint#7312

Merged
sfmskywalker merged 2 commits intocopilot/expose-api-endpoint-consumersfrom
copilot/sub-pr-7309
Feb 19, 2026
Merged

Deterministic ZIP export and 404 test coverage for consumers endpoint#7312
sfmskywalker merged 2 commits intocopilot/expose-api-endpoint-consumersfrom
copilot/sub-pr-7309

Conversation

Copy link
Contributor

Copilot AI commented Feb 19, 2026

Two unresolved review comments addressed: ZIP export was non-deterministic across identical inputs, and the consumers endpoint lacked test coverage for the 404 path.

Changes

  • Deterministic ZIP output (Export/Endpoint.cs)

    • Sort definitions by DefinitionId before writing entries — eliminates ordering variance from DB query results
    • Set entry.LastWriteTime = DateTimeOffset.UnixEpoch on every ZipArchiveEntry — eliminates timestamp variance in ZIP headers
  • 404 test coverage (WorkflowReferenceGraphTests.cs)

    • Added ConsumersEndpoint_UnknownWorkflow_ReturnsNotFound: calls GetConsumersAsync with a non-existent definition ID and asserts Refit.ApiException with HttpStatusCode.NotFound

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Co-authored-by: sfmskywalker <938393+sfmskywalker@users.noreply.github.com>
Copilot AI changed the title [WIP] Expose consumers API and recursive export option Deterministic ZIP export and 404 test coverage for consumers endpoint Feb 19, 2026
Copilot AI requested a review from sfmskywalker February 19, 2026 20:30
@sfmskywalker sfmskywalker marked this pull request as ready for review February 19, 2026 20:35
@sfmskywalker sfmskywalker merged commit 3f8b0af into copilot/expose-api-endpoint-consumers Feb 19, 2026
1 check passed
@sfmskywalker sfmskywalker deleted the copilot/sub-pr-7309 branch February 19, 2026 20:35
@greptile-apps
Copy link
Contributor

greptile-apps bot commented Feb 19, 2026

Greptile Summary

This PR addresses two specific code review comments by ensuring deterministic ZIP exports and adding test coverage for the 404 error path in the consumers endpoint.

  • Deterministic ZIP export: Sorts workflow definitions by DefinitionId before creating archive entries and sets LastWriteTime to DateTimeOffset.UnixEpoch to eliminate ordering and timestamp variance
  • 404 test coverage: Added ConsumersEndpoint_UnknownWorkflow_ReturnsNotFound test that verifies the consumers endpoint correctly returns 404 for non-existent workflow definitions

The changes are minimal, focused, and directly address the stated review comments without introducing side effects.

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • The changes are well-scoped bug fixes that improve determinism and test coverage. The ZIP export sorting and timestamp normalization are straightforward additions that don't affect business logic. The new test follows existing patterns and properly validates 404 behavior.
  • No files require special attention

Important Files Changed

Filename Overview
src/modules/Elsa.Workflows.Api/Endpoints/WorkflowDefinitions/Export/Endpoint.cs Adds deterministic ZIP export by sorting definitions by DefinitionId and setting LastWriteTime to Unix epoch
test/component/Elsa.Workflows.ComponentTests/Scenarios/WorkflowReferenceGraph/WorkflowReferenceGraphTests.cs Adds 404 test coverage for consumers endpoint with non-existent workflow definition ID

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[WriteZipResponseAsync] --> B[Sort definitions by DefinitionId]
    B --> C[Create ZIP Archive]
    C --> D[For each sorted definition]
    D --> E[Create WorkflowModel]
    E --> F[Serialize to JSON]
    F --> G[Create ZIP entry with filename]
    G --> H[Set LastWriteTime to UnixEpoch]
    H --> I[Write JSON to entry stream]
    I --> J{More definitions?}
    J -->|Yes| D
    J -->|No| K[Send ZIP to client]
Loading

Last reviewed commit: 7314adb

sfmskywalker added a commit that referenced this pull request Feb 20, 2026
* Initial plan

* Add consumers API endpoint and enhance export with IncludeConsumingWorkflows option

- New endpoint: GET /workflow-definitions/{definitionId}/consumers
- Export request model: added IncludeConsumingWorkflows boolean property
- Export endpoint: recursive consumer discovery and inclusion in exports

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

* Address greptile-apps feedback: fix double-fetch, remove redundant HashSet, add version comment, remove unused params

- Extract WriteZipResponseAsync helper to avoid double-fetching definitions from DB
- Remove redundant existingDefinitionIds HashSet in IncludeConsumersAsync
- Add XML doc comment documenting that consumers are resolved at VersionOptions.Latest
- Remove unused constructor parameters (workflowDefinitionService, variableDefinitionMapper)

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

* Address greptile-apps round 2: 404 for unknown definitions, deterministic ZIP response, parallel BFS

- Consumers endpoint now returns 404 when the definition ID doesn't exist
- Single-workflow export always returns ZIP when includeConsumingWorkflows=true
- BFS traversal processes each frontier level concurrently via Task.WhenAll

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

* Implement workflow reference graph feature

- Added `IWorkflowReferenceGraphBuilder` interface for building complete graphs of workflow references.
- Created `WorkflowReferenceGraph` and `WorkflowReferenceEdge` models.
- Implemented `WorkflowReferenceGraphBuilder` service for recursive graph building.
- Replaced previous workflow reference query logic with the new graph-based approach in consumers.

* Refactor workflow consumers to utilize recursive graph-based approach for retrieving consumer definitions.

* Enhance workflow export by adding support for including consuming workflows and update nullable default values across endpoints and models.

* Add WorkflowReferenceGraphOptions for depth and definition limit configuration

- Introduced `WorkflowReferenceGraphOptions` to configure max depth and definition limits for reference graph building.
- Updated `WorkflowManagementFeature` to support configuring these options.
- Enhanced `WorkflowReferenceGraphBuilder` to respect configuration limits during graph construction process.

* Refactor `WorkflowReferenceGraphBuilder` to utilize target-typed new expressions for cleaner code.

* Add Workflow Reference Graph tests and scenarios

Introduced JSON files for parent-child-grandchild workflow hierarchy tests and implemented unit tests for `WorkflowReferenceGraphBuilder`. Also added component tests for workflow export and consumers endpoint validation. Updated project configuration for workflow JSON to always copy to output directory.

* Include DefinitionId in exported workflow definition filenames for uniqueness.

* Remove unused models and constants from `WorkflowReferenceGraphTests`.

* Refactor `WorkflowReferenceGraphBuilderTests`: streamline test setup with `SetupGraph`, replace repeated assertions with helper methods.

* Deterministic ZIP export and 404 test coverage for consumers endpoint (#7312)

* Initial plan

* Fix deterministic ZIP export and add 404 test for consumers endpoint

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>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: sfmskywalker <938393+sfmskywalker@users.noreply.github.com>
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.

2 participants