Skip to content

add stack status to proto#2046

Open
jordanstephens wants to merge 2 commits intomainfrom
jordan/stack-status
Open

add stack status to proto#2046
jordanstephens wants to merge 2 commits intomainfrom
jordan/stack-status

Conversation

@jordanstephens
Copy link
Copy Markdown
Member

@jordanstephens jordanstephens commented Apr 10, 2026

Description

We are going to have fabric determine stack status server side and include the result in this response

Linked Issues

Checklist

  • I have performed a self-review of my code
  • I have added appropriate tests
  • I have updated the Defang CLI docs and/or README to reflect my changes, if necessary

Summary by CodeRabbit

  • New Features
    • Stack status is now included with stack details, showing STATUS values: Unspecified, Up, and Down.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 10, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 8b46b6ed-61c5-45b0-a24d-af01f4ab4f71

📥 Commits

Reviewing files that changed from the base of the PR and between f6086a0 and 35276aa.

⛔ Files ignored due to path filters (1)
  • src/protos/io/defang/v1/fabric.pb.go is excluded by !**/*.pb.go
📒 Files selected for processing (1)
  • src/protos/io/defang/v1/fabric.proto
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/protos/io/defang/v1/fabric.proto

📝 Walkthrough

Walkthrough

Added a new StackStatus enum with values STACK_STATUS_UNSPECIFIED, STACK_STATUS_UP, and STACK_STATUS_DOWN, and a status field (field 10) to the Stack message in the fabric protobuf schema to convey stack operational state.

Changes

Cohort / File(s) Summary
Protobuf Schema Extension
src/protos/io/defang/v1/fabric.proto
Introduced StackStatus enum (UNSPECIFIED=0, UP=1, DOWN=2) and added Stack.status = 10 to the Stack message to expose stack status in API payloads.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Suggested reviewers

  • lionello

Poem

🐰✨ I dug a tiny proto hole today,
A status flag hopped in to stay,
UP, DOWN, or UNSPECIFIED — I sing with delight,
Fields now number ten, everything feels right,
Hooray for small changes that make systems bright!

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding a stack status field to the Protocol Buffer definitions.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch jordan/stack-status

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

Copy link
Copy Markdown
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

🧹 Nitpick comments (1)
src/protos/io/defang/v1/fabric.proto (1)

166-170: Consider prefixing StackStatus enum values for consistency with protocol buffers naming conventions.

At lines 168-169, UP and DOWN are generic names. Protocol buffers convention recommends prefixing enum values with their enum type name (e.g., STACK_STATUS_UP, STACK_STATUS_DOWN) for improved clarity across language bindings and consistency with patterns elsewhere in proto schemas.

Suggested refactoring
 enum StackStatus {
   STACK_STATUS_UNSPECIFIED = 0;
-  UP = 1;
-  DOWN = 2;
+  STACK_STATUS_UP = 1;
+  STACK_STATUS_DOWN = 2;
 }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/protos/io/defang/v1/fabric.proto` around lines 166 - 170, Rename the enum
values in StackStatus so they are prefixed with the enum name: change UP to
STACK_STATUS_UP and DOWN to STACK_STATUS_DOWN (leave STACK_STATUS_UNSPECIFIED
as-is); update all usages/references of StackStatus.UP and StackStatus.DOWN
throughout the codebase (and regenerate any generated protobuf artifacts) to use
StackStatus.STACK_STATUS_UP and StackStatus.STACK_STATUS_DOWN to maintain
consistency with protobuf naming conventions.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/protos/io/defang/v1/fabric.proto`:
- Line 182: Add the google.api.field_behavior import and mark the Stack.status
field as OUTPUT_ONLY so clients cannot set it; update the proto by importing
"google/api/field_behavior.proto" and annotate the Stack.message's status field
(Stack.status) with the google.api.field_behavior = OUTPUT_ONLY option to
enforce server-managed semantics (also verify usages like PutStackRequest that
embed Stack reflect the intent).

---

Nitpick comments:
In `@src/protos/io/defang/v1/fabric.proto`:
- Around line 166-170: Rename the enum values in StackStatus so they are
prefixed with the enum name: change UP to STACK_STATUS_UP and DOWN to
STACK_STATUS_DOWN (leave STACK_STATUS_UNSPECIFIED as-is); update all
usages/references of StackStatus.UP and StackStatus.DOWN throughout the codebase
(and regenerate any generated protobuf artifacts) to use
StackStatus.STACK_STATUS_UP and StackStatus.STACK_STATUS_DOWN to maintain
consistency with protobuf naming conventions.
🪄 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: defaults

Review profile: CHILL

Plan: Pro

Run ID: d9ba03d7-78fa-44d6-87af-cedcce66d5e6

📥 Commits

Reviewing files that changed from the base of the PR and between e25fb82 and f6086a0.

⛔ Files ignored due to path filters (1)
  • src/protos/io/defang/v1/fabric.pb.go is excluded by !**/*.pb.go
📒 Files selected for processing (1)
  • src/protos/io/defang/v1/fabric.proto

string region = 7;
DeploymentMode mode = 8;
bool is_default = 9;
StackStatus status = 10;
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot Apr 10, 2026

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== PutStack handler definitions =="
rg -nP --type=go -C4 '\bPutStack\s*\([^)]*\*defangv1\.PutStackRequest' 

echo
echo "== Reads of client-provided stack status in PutStack flow =="
rg -nP --type=go -C4 'GetStack\(\)\.GetStatus\(\)|\.Stack\.Status|GetStatus\(\)' 

echo
echo "== Writes of stack status in server responses/storage path =="
rg -nP --type=go -C4 'StackStatus|STATUS_UP|STATUS_DOWN|status\s*:'

Repository: DefangLabs/defang

Length of output: 28491


🏁 Script executed:

cat -n src/protos/io/defang/v1/fabric.proto | sed -n '170,200p'

Repository: DefangLabs/defang

Length of output: 817


🏁 Script executed:

rg -n "message Stack|message PutStackRequest" -A 15 src/protos/io/defang/v1/fabric.proto

Repository: DefangLabs/defang

Length of output: 713


🏁 Script executed:

# Look for where Stack objects are created/modified in request path
rg -n "stack.*=.*&defangv1\.Stack|\.Status\s*=" --type=go | grep -i "putstack\|request" | head -20

Repository: DefangLabs/defang

Length of output: 43


🏁 Script executed:

# Find server-side implementations of PutStack (usually in gRPC service handlers)
rg -n "func.*PutStack" --type=go -B 2 -A 8 | grep -v test | head -40

Repository: DefangLabs/defang

Length of output: 3736


🏁 Script executed:

# Search for fabric service implementations
fd -name "*.go" -path "*/service*" -o -path "*/server*" | xargs rg -l "PutStack" 2>/dev/null | head -5

Repository: DefangLabs/defang

Length of output: 435


🏁 Script executed:

# More specific: look for proto service implementation handling
rg -n "PutStack\(" --type=go -B 2 -A 10 | grep -E "(func|Stack|status)" | head -30

Repository: DefangLabs/defang

Length of output: 3395


🏁 Script executed:

# Find where PutStack is actually implemented (server handler)
find src/pkg -name "*.go" -type f | xargs rg "func.*PutStack.*ctx" 2>/dev/null | grep -v test | grep -v "interface"

Repository: DefangLabs/defang

Length of output: 298


🏁 Script executed:

# Look for fabric service implementation
fd "fabric" --type f --path "*/service*" src/pkg

Repository: DefangLabs/defang

Length of output: 294


🏁 Script executed:

# Search more broadly for server implementation
rg "PutStack.*context.Context.*\*defangv1.PutStackRequest" --type=go -A 15 | head -60

Repository: DefangLabs/defang

Length of output: 3538


🏁 Script executed:

# Search for FabricController implementation across entire src/pkg
rg "type.*FabricController" --type=go -A 2

Repository: DefangLabs/defang

Length of output: 1502


🏁 Script executed:

# Look for any PutStack implementation that's not a client wrapper
rg "func.*FabricController.*PutStack|func.*Server.*PutStack" --type=go -A 12

Repository: DefangLabs/defang

Length of output: 1847


🏁 Script executed:

# Broader search for where Stack.Status might be set or used in responses
rg "\.Status\s*=" --type=go | grep -i stack | grep -v test | head -20

Repository: DefangLabs/defang

Length of output: 43


🏁 Script executed:

# Look for GetStack or ListStacks implementations that might populate status
rg "GetStack|ListStack" --type=go -A 10 | grep -E "(Status|status)" -B 2 -A 2 | head -40

Repository: DefangLabs/defang

Length of output: 2705


🏁 Script executed:

# Check if there's a separate service directory or different code structure
find src -type d -name "*service*" -o -name "*server*" -o -name "*handler*"

Repository: DefangLabs/defang

Length of output: 216


🏁 Script executed:

# Look for any database/storage interactions with Stack
rg "db.*Stack|storage.*Stack|sql.*Stack" --type=go -l | head -10

Repository: DefangLabs/defang

Length of output: 43


🏁 Script executed:

# Final verification: check if there's any mention of output_only or field_behavior in existing protos
rg "OUTPUT_ONLY|field_behavior" src/protos/

Repository: DefangLabs/defang

Length of output: 43


🏁 Script executed:

# Check what google.api imports currently exist
rg "import.*google.api" src/protos/io/defang/v1/fabric.proto

Repository: DefangLabs/defang

Length of output: 43


Add OUTPUT_ONLY annotation to Stack.status to enforce server-managed semantics.

Line 182 adds status to the Stack message, which is embedded in PutStackRequest (line 186). This allows clients to set a field that should be server-determined. Add the google.api.field_behavior import and mark status as output-only to prevent accidental misuse and clarify the contract.

Suggested proto contract hardening
 import "google/protobuf/empty.proto";
 import "google/protobuf/timestamp.proto";
 import "google/type/money.proto";
+import "google/api/field_behavior.proto";
@@
-  StackStatus status = 10;
+  StackStatus status = 10 [(google.api.field_behavior) = OUTPUT_ONLY];
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/protos/io/defang/v1/fabric.proto` at line 182, Add the
google.api.field_behavior import and mark the Stack.status field as OUTPUT_ONLY
so clients cannot set it; update the proto by importing
"google/api/field_behavior.proto" and annotate the Stack.message's status field
(Stack.status) with the google.api.field_behavior = OUTPUT_ONLY option to
enforce server-managed semantics (also verify usages like PutStackRequest that
embed Stack reflect the intent).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Alternatively, we can add a new rpc GetStackStatus instead.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@lionello, that's a valid alternative worth weighing. Here's a quick comparison of both approaches:

Stack.status (OUTPUT_ONLY) New GetStackStatus RPC
Client ergonomics Status returned inline with GetStack/ListStacks — no extra roundtrip Separate call required to check status
API clarity Requires OUTPUT_ONLY annotation to signal "server-managed, ignored on write" Unambiguous — no field in PutStackRequest to misinterpret
Proto contract Needs google/api/field_behavior.proto import + annotation Slightly more surface area (new request/response message + RPC)
Future extensibility Status detail (e.g. reason, timestamp) would still require a dedicated response type Easier to add rich status detail in a purpose-built response message

If the status is expected to be polled independently (e.g. to track provisioning progress), a dedicated GetStackStatus RPC makes the intent very clear and avoids any ambiguity about the PutStackRequest payload. If status is primarily an informational field always read alongside the stack config (like is_default or last_deployed_at), keeping it in Stack with an OUTPUT_ONLY annotation is the lighter, more idiomatic choice.

Either way, the concern about PutStack accepting an ignored status field can be addressed — either by the new RPC design or the annotation. Which pattern better fits how callers will use this in practice?

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