Add Get capability steps endpoint - #108
Conversation
- Implement `GetCapabilitySteps` service method to retrieve steps for a given capability.
- Add `GET /capabilities/{id}/steps` route to the router.
- Create `GetCapabilitySteps` handler with validation, timeout, and error handling.
- Extend unit tests for handler, service, and route to cover success, not found, invalid ID, and error cases.
- Update mock services with `GetCapabilitySteps` function for testing.
…te error messaging - Replace local `NotFoundError` with `internal.NotFoundError` in service methods and tests for consistency. - Update error messages in capability service and tests for improved clarity (`capability not found with ID: <id>`). - Ensure `nil` is returned for empty capability steps in service methods.
- Create YAML definition for `Get Capability Steps` with HTTP GET request, path parameter, and assertions. - Include example request, response, and documentation for retrieving steps associated with a capability.
|
Warning Review limit reached
Next review available in: 39 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughAdds ChangesCapability steps retrieval
Estimated code review effort: 3 (Moderate) | ~20 minutes Possibly related issues
Possibly related PRs
Suggested labels: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
internal/capability/handler.go (1)
206-225: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueUse context-aware logger for consistency.
Other handlers in this file use
internal.LoggerFromContext(r.Context())to ensure context-specific fields (like request IDs) are included in the logs. Please update this log statement to match the established pattern.♻️ Proposed refactor
- slog.Error("Failed to fetch capability steps", slog.Int("capability_id", id), slog.String("error", err.Error())) + internal.LoggerFromContext(r.Context()).Error("Failed to fetch capability steps", slog.Int("capability_id", id), slog.String("error", err.Error()))🤖 Prompt for 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. In `@internal/capability/handler.go` around lines 206 - 225, Replace the package-level slog.Error call in GetCapabilitySteps with the context-aware logger obtained from internal.LoggerFromContext(r.Context()), preserving the existing message and capability_id/error fields.
🤖 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 `@_bruno/Capabilities/Get` Capability Steps.yml:
- Around line 71-76: Update the status-code table in the Get Capability steps so
the 200 response note reads “OK” instead of “Created”; leave the other status
descriptions unchanged.
In `@internal/capability/service_capability_steps_test.go`:
- Around line 286-343: Add a “NoStepsFound” subtest to TestGetCapabilitySteps
where GetCapabilityStepsFunc returns a nil slice with no error; call
GetCapabilitySteps and assert no error plus a non-nil empty result, covering the
nil-to-empty conversion.
---
Nitpick comments:
In `@internal/capability/handler.go`:
- Around line 206-225: Replace the package-level slog.Error call in
GetCapabilitySteps with the context-aware logger obtained from
internal.LoggerFromContext(r.Context()), preserving the existing message and
capability_id/error fields.
🪄 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: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: d0bc8404-fd31-40bc-8e0b-63b2c6dc4547
📒 Files selected for processing (10)
_bruno/Capabilities/Get Capability Steps.ymlinternal/capability/handler.gointernal/capability/handler_command_cap_step_test.gointernal/capability/handler_test.gointernal/capability/router.gointernal/capability/router_test.gointernal/capability/service_capability.gointernal/capability/service_capability_steps.gointernal/capability/service_capability_steps_test.gointernal/capability/service_capability_test.go
- Introduce `NoStepsFound` test case to ensure the service returns an empty, non-nil slice when no steps are present. - Extend mock `GetCapabilityStepsFunc` to return an empty result for validation.
Description
This diverges from the issue, but this is clearer for front end use
Code Rabbit Summary
Summary by CodeRabbit
New Features
GET /capabilities/{id}/steps.Bug Fixes
Tests
Fixes
Closes #103