Skip to content

Conversation

@lionello
Copy link
Member

@lionello lionello commented Dec 12, 2025

Description

Change error message: when no services were found, suggest to check logs for deployment status.

Summary by CodeRabbit

  • Bug Fixes

    • Clarified "no services found" messaging (project quoted, guidance to check deployment logs).
    • Improved error consistency so callers and UI receive the correct empty-service error type.
    • Simplified logs command error propagation to avoid wrapped error text.
  • Refactor

    • Unified service listing and health-check flow; ps now uses the unified print path for consistent output and state display.
  • Style

    • Removed stray blank lines for cleaner code and tests.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 12, 2025

Walkthrough

Replaces local deployment_info types with cli.Service, splits retrieval vs presentation (adds PrintServices), updates interfaces/implementations and tests to use []*cli.Service, standardizes "no services" error text, adds BYOC project path helper, and includes minor whitespace/comment and test-file deletions.

Changes

Cohort / File(s) Summary
CLI service surface
src/pkg/cli/getServices.go, src/pkg/cli/deploymentinfo.go, src/pkg/cli/getServices_test.go
Split data vs presentation: GetServices now returns a response, PrintServices added; printService renamed to exported Service; added GetServiceStatesAndEndpoints; healthcheck URL construction and endpoint filtering adjusted; tests updated to call PrintServices.
Agent/tooling interfaces & impl
src/pkg/agent/tools/interfaces.go, src/pkg/agent/tools/default_tool_cli.go, src/pkg/agent/tools/services.go, src/pkg/agent/tools/services_test.go, src/pkg/agent/tools/logs.go
Tool API migrated to []*cli.Service; signatures for GetServices, Tail, TailAndMonitor updated; mocks/tests updated to *cli.Service types; HandleServicesTool now surfaces underlying error string for no-services; Tail error wrapping removed.
Removed deployment_info package file
src/pkg/mcp/deployment_info/deployment_info.go
Deleted file and its exported types/functions (ErrNoServices, Service, GetServices) — callers migrated to cli equivalents.
BYOC path helpers
src/pkg/cli/client/byoc/baseclient.go, src/pkg/cli/client/byoc/aws/byoc.go, src/pkg/cli/client/byoc/do/byoc.go, src/pkg/cli/client/byoc/gcp/byoc.go
Added GetProjectUpdatePath(projectName string) and replaced inline project-update path construction with this helper across BYOC clients.
Compose command integration
src/cmd/cli/command/compose.go
ps command now calls cli.PrintServices (presentation split) instead of the old cli.GetServices usage; error handling preserved.
Whitespace / comments / small tests
src/cmd/cli/command/globals.go, src/cmd/cli/command/globals_test.go, src/pkg/migrate/heroku.go, src/pkg/cli/client/byoc/aws/domain_integration_test.go
Minor whitespace/comment edits and removal of an AWS BYOC integration test file.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

  • Files/areas needing extra attention:
    • All call sites updated for removal of deployment_info types and new []*cli.Service signatures.
    • Correct detection/handling of ErrNoServices (type vs message and where it's constructed/compared).
    • Healthcheck URL construction (use of url.JoinPath) and filtering of endpoints that include ports.
    • BYOC GetProjectUpdatePath validation and how callers rely on path format.
    • Tests and mocks updated to use *cli.Service and new error/message expectations.

Possibly related PRs

Suggested reviewers

  • jordanstephens

Poem

🐇 I hopped through diffs, renamed a thing,

Services nested under one bright spring,
Paths cleaned up, tests given a shove,
Quiet blanks trimmed with rabbit love,
A tiny hop — code-ordering up above 🥕

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 8.33% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix: suggest to check logs if no services are found' directly aligns with the main change: updating error messaging to suggest checking logs when no services are found.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch lio/no-services-check-logs

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b225d44 and 4a29145.

📒 Files selected for processing (1)
  • src/pkg/agent/tools/logs.go (0 hunks)
💤 Files with no reviewable changes (1)
  • src/pkg/agent/tools/logs.go
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Analyze (go)
  • GitHub Check: go-test

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

@lionello lionello requested a review from KevyVo December 12, 2025 05:56
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (2)
src/pkg/agent/tools/services.go (1)

44-55: Prefer returning noServicesErr.Error() (stable user-facing text) instead of err.Error() (may include wrappers).
Right now, if upstream wraps ErrNoServices, the user may see extra prefix text even though you successfully errors.As-matched the typed error.

-        if errors.As(err, &noServicesErr) {
-            return err.Error(), nil
-        }
+        if errors.As(err, &noServicesErr) {
+            return noServicesErr.Error(), nil
+        }
src/pkg/agent/tools/services_test.go (1)

190-204: Add an assertion for the new “check logs for deployment status” guidance.
Current expectation only checks the prefix, so a regression could drop the guidance without failing tests.

-            resultTextContains:  "no services found in project",
+            resultTextContains:  "no services found in project",
+            // consider also asserting: "check logs for deployment status"

(If you prefer keeping one field, you could add a second assert.Contains(t, result, "...") in the test body for this case.)

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8ac815c and c0977b1.

📒 Files selected for processing (7)
  • src/cmd/cli/command/globals.go (0 hunks)
  • src/cmd/cli/command/globals_test.go (0 hunks)
  • src/pkg/agent/tools/services.go (1 hunks)
  • src/pkg/agent/tools/services_test.go (1 hunks)
  • src/pkg/cli/getServices.go (2 hunks)
  • src/pkg/mcp/deployment_info/deployment_info.go (2 hunks)
  • src/pkg/migrate/heroku.go (1 hunks)
💤 Files with no reviewable changes (2)
  • src/cmd/cli/command/globals.go
  • src/cmd/cli/command/globals_test.go
🧰 Additional context used
🧬 Code graph analysis (1)
src/pkg/mcp/deployment_info/deployment_info.go (1)
src/pkg/cli/getServices.go (1)
  • ErrNoServices (16-18)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: nix-shell-test
  • GitHub Check: go-playground-test
  • GitHub Check: Analyze (go)
🔇 Additional comments (3)
src/pkg/migrate/heroku.go (1)

336-343: Doc comment spacing change only; no functional impact. The added blank comment lines read fine and won’t affect behavior.

src/pkg/cli/getServices.go (1)

3-25: Updated ErrNoServices message is clear and consistent (includes “check logs…” and quotes project).
No concerns with the fmt.Sprintf(...%q...) change.

src/pkg/mcp/deployment_info/deployment_info.go (1)

3-34: No import cycle detected. The search confirmed that src/pkg/cli does not import src/pkg/mcp/deployment_info (directly or indirectly), so the new dependency is safe and will not break builds.

Copy link
Contributor

@KevyVo KevyVo left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
src/pkg/cli/getServices_test.go (1)

73-79: Exercise the intended long path in “no services long” test

The “no services long” subtest still calls PrintServices(..., false) (Line 108), so it’s not actually covering the long-output variant.

- err := PrintServices(ctx, "empty", &provider, false)
+ err := PrintServices(ctx, "empty", &provider, true)
src/pkg/cli/deploymentinfo.go (1)

17-50: Defensive nil-check for serviceInfo.Service to avoid panic

Since ServiceInfo.Service originates from RPC responses, consider guarding serviceInfo.Service == nil before accessing .Name.

🧹 Nitpick comments (2)
src/pkg/cli/getServices_test.go (1)

73-79: Nit: update failure strings referencing GetServices()

A few t.Fatalf(...) messages still say GetServices() even though the test now calls PrintServices().

Also applies to: 81-87, 107-112, 115-121

src/pkg/agent/tools/services_test.go (1)

10-13: Avoid importing the same package twice (cli vs defangcli)

This is the same module path imported under two names; consider keeping one alias to reduce confusion.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f3b483e and ed0833f.

📒 Files selected for processing (13)
  • src/cmd/cli/command/compose.go (1 hunks)
  • src/pkg/agent/tools/default_tool_cli.go (1 hunks)
  • src/pkg/agent/tools/interfaces.go (1 hunks)
  • src/pkg/agent/tools/services_test.go (5 hunks)
  • src/pkg/cli/client/byoc/aws/byoc.go (1 hunks)
  • src/pkg/cli/client/byoc/aws/domain_integration_test.go (0 hunks)
  • src/pkg/cli/client/byoc/baseclient.go (1 hunks)
  • src/pkg/cli/client/byoc/do/byoc.go (1 hunks)
  • src/pkg/cli/client/byoc/gcp/byoc.go (1 hunks)
  • src/pkg/cli/deploymentinfo.go (4 hunks)
  • src/pkg/cli/getServices.go (3 hunks)
  • src/pkg/cli/getServices_test.go (4 hunks)
  • src/pkg/mcp/deployment_info/deployment_info.go (0 hunks)
💤 Files with no reviewable changes (2)
  • src/pkg/cli/client/byoc/aws/domain_integration_test.go
  • src/pkg/mcp/deployment_info/deployment_info.go
🧰 Additional context used
🧬 Code graph analysis (7)
src/pkg/cli/getServices_test.go (1)
src/pkg/cli/getServices.go (1)
  • PrintServices (44-58)
src/pkg/cli/client/byoc/baseclient.go (1)
src/pkg/utils.go (1)
  • Ensure (135-139)
src/cmd/cli/command/compose.go (1)
src/pkg/cli/getServices.go (1)
  • PrintServices (44-58)
src/pkg/agent/tools/default_tool_cli.go (3)
src/pkg/cli/getServices.go (2)
  • GetServices (28-42)
  • UpdateServiceStates (60-103)
src/pkg/cli/deploymentinfo.go (2)
  • Service (8-15)
  • GetServiceStatesAndEndpoints (17-53)
src/pkg/cli/compose/loader.go (1)
  • Services (29-29)
src/pkg/agent/tools/services_test.go (2)
src/pkg/cli/deploymentinfo.go (1)
  • Service (8-15)
src/pkg/cli/getServices.go (1)
  • GetServices (28-42)
src/pkg/cli/deploymentinfo.go (2)
src/protos/io/defang/v1/fabric.pb.go (6)
  • ServiceInfo (2065-2088)
  • ServiceInfo (2101-2101)
  • ServiceInfo (2116-2118)
  • Service (3816-3821)
  • Service (3834-3834)
  • Service (3849-3851)
src/pkg/term/table.go (1)
  • Table (11-13)
src/pkg/cli/getServices.go (2)
src/protos/io/defang/v1/fabric.pb.go (16)
  • Provider (28-28)
  • Provider (66-68)
  • Provider (70-72)
  • Provider (79-81)
  • GetServicesResponse (3593-3600)
  • GetServicesResponse (3613-3613)
  • GetServicesResponse (3628-3630)
  • GetServicesRequest (4143-4148)
  • GetServicesRequest (4161-4161)
  • GetServicesRequest (4176-4178)
  • ServiceInfo (2065-2088)
  • ServiceInfo (2101-2101)
  • ServiceInfo (2116-2118)
  • Service (3816-3821)
  • Service (3834-3834)
  • Service (3849-3851)
src/pkg/cli/client/provider.go (1)
  • Provider (43-69)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Analyze (go)
  • GitHub Check: go-test
🔇 Additional comments (12)
src/pkg/cli/client/byoc/do/byoc.go (1)

99-99: LGTM: Delegation to centralized path helper.

The refactoring to use GetProjectUpdatePath successfully centralizes path construction logic across BYOC providers.

src/pkg/cli/client/byoc/baseclient.go (1)

295-299: LGTM: Helper centralizes path construction.

The new helper method successfully consolidates duplicate path logic from multiple BYOC providers. The validation using pkg.Ensure is appropriate for an internal precondition check.

src/pkg/cli/client/byoc/gcp/byoc.go (1)

960-960: LGTM: Consistent with path helper refactoring.

The change aligns with the centralized path construction pattern applied across all BYOC providers.

src/pkg/cli/client/byoc/aws/byoc.go (1)

494-494: LGTM: Completes path helper refactoring.

The change successfully centralizes path construction logic, ensuring consistency across all BYOC provider implementations.

src/pkg/cli/getServices_test.go (1)

73-105: PrintServices migration in tests looks consistent

Switching the test coverage to PrintServices(...) matches the new split between data retrieval and presentation.

src/cmd/cli/command/compose.go (1)

593-611: Correctly routes ps through cli.PrintServices

Caller remains responsible for handling cli.ErrNoServices, while printing stays encapsulated in the cli package.

src/pkg/agent/tools/default_tool_cli.go (1)

72-83: GetServices tool wiring matches new cli service model

Implementation is consistent with the refactor (fetch → health update → convert-to-view).

src/pkg/agent/tools/services_test.go (1)

59-67: Tests updated cleanly to []*cli.Service and new no-services message

Also applies to: 190-205, 233-253

src/pkg/agent/tools/interfaces.go (1)

15-34: Interface updates align with the new cli types (Service, TailOptions)

src/pkg/cli/deploymentinfo.go (1)

55-76: Nice separation: data shaping vs printing

src/pkg/cli/getServices.go (2)

21-26: ErrNoServices message matches the PR goal (“check logs…”)


28-58: Good split: GetServices (data) vs PrintServices (presentation)

@jordanstephens jordanstephens merged commit 1379dab into main Dec 12, 2025
14 checks passed
@jordanstephens jordanstephens deleted the lio/no-services-check-logs branch December 12, 2025 18:34
This was referenced Dec 12, 2025
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.

4 participants