BCH-1148: Populate step_count in workflow definition list response#398
Conversation
The API preloaded Steps but never exposed a step count field, causing the UI to always display 0 steps for workflow definitions. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughAdds a non-persisted integer StepCount to WorkflowDefinition, exposes it in Go and Swagger schemas, populates it from preloaded Steps in service read methods, and adds a GetAll unit test asserting expected counts. ChangesWorkflow Step Count Field
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Comment |
There was a problem hiding this comment.
Actionable comments posted: 4
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@docs/docs.go`:
- Around line 40169-40172: Update the Go struct comment for the StepCount field
so the generated Swagger description is singular: change the comment on
StepCount in workflow_definition.go from "Computed fields (not persisted)" to
"Computed field (not persisted)". Regenerate the docs with swag so docs/docs.go
reflects the corrected "step_count" description.
In `@docs/swagger.json`:
- Around line 40163-40166: The step_count property in the OpenAPI schema
currently lacks a minimum constraint; update the "step_count" schema (type:
integer) to include "minimum": 0 so negative values are disallowed and the API
contract documents that counts cannot be negative.
In `@internal/service/relational/workflows/workflow_definition_service_test.go`:
- Around line 101-118: Add an assertion that workflow definitions with no
associated steps report StepCount == 0: after calling
NewWorkflowDefinitionService(db) and creating a definition without steps (as
done in TestWorkflowDefinitionService_GetAll or the existing setup in
TestWorkflowDefinitionService_GetAll_StepCount), call service.GetAll(...) and
assert that the returned retrieved[n].StepCount equals 0 for that definition;
reference the GetAll method and the retrieved slice to locate where to add the
assertion.
In `@internal/service/relational/workflows/workflow_definition_service.go`:
- Around line 66-68: FindByName, GetByID, and GetWithInstances preload Steps but
never set the computed StepCount field, causing inconsistent API responses;
after each place you load a WorkflowDefinition (e.g., the returned variable
named definitions or def), set def.StepCount = len(def.Steps) (or for slices
loop and set definitions[i].StepCount = len(definitions[i].Steps)) before
returning so StepCount is populated consistently across those methods (update in
FindByName, GetByID, and GetWithInstances).
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: da734735-8214-40ba-b366-b310db37941b
📒 Files selected for processing (6)
docs/docs.godocs/swagger.jsondocs/swagger.yamlinternal/service/relational/workflows/workflow_definition.gointernal/service/relational/workflows/workflow_definition_service.gointernal/service/relational/workflows/workflow_definition_service_test.go
- Fix grammar: singular "Computed field" in StepCount doc comment - Add validate:"min=0" tag so swagger emits minimum:0 constraint - Populate StepCount in GetByID, FindByName, and GetWithInstances for consistent API responses - Add zero-step assertion to TestWorkflowDefinitionService_GetAll_StepCount Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

The API preloaded Steps but never exposed a step count field, causing the UI to always display 0 steps for workflow definitions.
Summary by CodeRabbit
New Features
Documentation
Tests