Skip to content

Add Get capability steps endpoint - #108

Merged
jlpdeveloper merged 5 commits into
mainfrom
capability-steps/get
Jul 15, 2026
Merged

Add Get capability steps endpoint#108
jlpdeveloper merged 5 commits into
mainfrom
capability-steps/get

Conversation

@jlpdeveloper

@jlpdeveloper jlpdeveloper commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Description

This diverges from the issue, but this is clearer for front end use

Code Rabbit Summary

Summary by CodeRabbit

  • New Features

    • Added an endpoint to retrieve the steps associated with a capability: GET /capabilities/{id}/steps.
    • Returns a JSON array of capability steps for valid capability IDs.
    • Added API request documentation and example responses.
  • Bug Fixes

    • Improved handling and messaging when capabilities cannot be found.
    • Invalid IDs, missing capabilities, and server errors now return appropriate responses.
  • Tests

    • Added coverage for successful retrieval and error scenarios.

Fixes

Closes #103

- 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.
@jlpdeveloper jlpdeveloper self-assigned this Jul 15, 2026
@coderabbitai

coderabbitai Bot commented Jul 15, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@jlpdeveloper, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 39 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: aa05cad6-4d42-486f-9607-7874c77869db

📥 Commits

Reviewing files that changed from the base of the PR and between 63123d7 and d7e3b51.

📒 Files selected for processing (2)
  • _bruno/Capabilities/Get Capability Steps.yml
  • internal/capability/service_capability_steps_test.go
📝 Walkthrough

Walkthrough

Adds GET /capabilities/{id}/steps, including service lookup, standardized not-found handling, HTTP error mapping, route and unit tests, and a Bruno request definition with examples and documentation.

Changes

Capability steps retrieval

Layer / File(s) Summary
Capability step service lookup
internal/capability/service_capability.go, internal/capability/service_capability_steps.go, internal/capability/*_test.go
Adds capability existence validation, database step retrieval, nil-to-empty-slice normalization, and standardized capability not-found errors with coverage for success and failure paths.
HTTP endpoint wiring and handling
internal/capability/handler.go, internal/capability/router.go, internal/capability/*_test.go
Registers GET /capabilities/{id}/steps, validates IDs, maps not-found and service errors to HTTP responses, and tests routing and handler scenarios.
Bruno request and documentation
_bruno/Capabilities/Get Capability Steps.yml
Defines the authenticated GET request, response assertions, sample payload, and documented status codes.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related issues

Possibly related PRs

Suggested labels: enhancement

Poem

A bunny found steps in a burrow so neat,
With GET on the trail and JSON to greet.
Four-oh-four thumps when the cap isn’t there,
Five-hundred clouds bring a logging scare.
The path is now mapped, the tests softly sing—
Hop, hop, retrieve every step of the thing!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main change: adding a GET capability steps endpoint.
Linked Issues check ✅ Passed The PR implements the requested GET endpoint and associated service, handler, route, tests, and docs.
Out of Scope Changes check ✅ Passed All code changes appear related to the new capability steps endpoint and its supporting error handling and tests.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch capability-steps/get

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (1)
internal/capability/handler.go (1)

206-225: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Use 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

📥 Commits

Reviewing files that changed from the base of the PR and between 57e14ff and 63123d7.

📒 Files selected for processing (10)
  • _bruno/Capabilities/Get Capability Steps.yml
  • internal/capability/handler.go
  • internal/capability/handler_command_cap_step_test.go
  • internal/capability/handler_test.go
  • internal/capability/router.go
  • internal/capability/router_test.go
  • internal/capability/service_capability.go
  • internal/capability/service_capability_steps.go
  • internal/capability/service_capability_steps_test.go
  • internal/capability/service_capability_test.go

Comment thread _bruno/Capabilities/Get Capability Steps.yml
Comment thread internal/capability/service_capability_steps_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.
@jlpdeveloper
jlpdeveloper merged commit 9940710 into main Jul 15, 2026
3 checks passed
@jlpdeveloper
jlpdeveloper deleted the capability-steps/get branch July 15, 2026 00:30
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.

Add GET endpoint

1 participant