-
Notifications
You must be signed in to change notification settings - Fork 693
feat(batch_execute): improve error handling with success detection an… #531
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(batch_execute): improve error handling with success detection an… #531
Conversation
…d fail-fast support - Add DetermineCallSucceeded() to check command success via IMcpResponse interface or JObject/JToken 'success' field - Track invocationFailureCount and set anyCommandFailed flag when commands fail - Implement fail-fast behavior to stop batch execution on first failure when failFast=true - Update commandResults to use computed callSucceeded value instead of hardcoded true feat(game_object_create): enhance asset
Reviewer's GuideRefines batch command execution success detection and fail-fast behavior while enhancing GameObject creation to better resolve prefab/asset paths and surface clearer error conditions. Sequence diagram for batch command execution with improved success detection and fail-fastsequenceDiagram
actor Caller
participant BatchExecute
participant CommandRegistry
participant ToolCommand
Caller->>BatchExecute: HandleCommand(params)
loop For each toolName in commands
BatchExecute->>CommandRegistry: InvokeCommandAsync(toolName, commandParams)
CommandRegistry->>ToolCommand: Execute(commandParams)
ToolCommand-->>CommandRegistry: result
CommandRegistry-->>BatchExecute: result
BatchExecute->>BatchExecute: DetermineCallSucceeded(result)
alt callSucceeded
BatchExecute->>BatchExecute: increment invocationSuccessCount
else callFailed
BatchExecute->>BatchExecute: increment invocationFailureCount
BatchExecute->>BatchExecute: set anyCommandFailed = true
alt failFast is true
BatchExecute->>BatchExecute: break command loop
end
end
BatchExecute->>BatchExecute: commandResults.Add({ tool, callSucceeded, result })
end
alt anyCommandFailed
BatchExecute-->>Caller: ErrorResponse("One or more commands failed", data)
else allSucceeded
BatchExecute-->>Caller: SuccessResponse(data)
end
Class diagram for updated batch execution and GameObject creation typesclassDiagram
class BatchExecute {
+static Task<object> HandleCommand(JObject params)
-static bool DetermineCallSucceeded(object result)
-int invocationSuccessCount
-int invocationFailureCount
-bool anyCommandFailed
-bool failFast
}
class IMcpResponse {
<<interface>>
+bool Success
}
class ErrorResponse {
+ErrorResponse(string message)
+ErrorResponse(string message, object data)
+bool Success
+string Message
+object Data
}
class GameObjectCreate {
+static object Handle(JObject params)
-string prefabPath
-bool saveAsPrefab
-GameObject prefabAsset
}
class AssetDatabase {
<<static>>
+static string[] FindAssets(string filter)
+static string GUIDToAssetPath(string guid)
+static T LoadAssetAtPath~T~(string path)
}
class McpLog {
<<static>>
+static void Info(string message)
+static void Warn(string message)
}
class JObject
class JToken
class GameObject
BatchExecute ..> IMcpResponse : uses via DetermineCallSucceeded
BatchExecute ..> ErrorResponse : returns on failure
ErrorResponse ..|> IMcpResponse
GameObjectCreate ..> AssetDatabase : resolves prefabPath
GameObjectCreate ..> McpLog : logs resolution steps
GameObjectCreate ..> ErrorResponse : returns on invalid asset
GameObjectCreate ..> GameObject : instantiates prefab
BatchExecute ..> JObject : HandleCommand params
BatchExecute ..> JToken : DetermineCallSucceeded(result)
GameObjectCreate ..> JObject : Handle params
Flow diagram for enhanced prefab and asset path resolution in GameObjectCreateflowchart TD
A["Start Handle(params)"] --> B{"saveAsPrefab is false?"}
B -- no --> Z["Skip prefab/asset lookup"]
B -- yes --> C{"prefabPath is null or empty?"}
C -- yes --> Z
C -- no --> D["Get extension = Path.GetExtension(prefabPath)"]
D --> E{"prefabPath contains '/'?"}
E -- no --> F{"extension is null or empty OR extension == .prefab?"}
F -- yes --> G["Search for prefab by name (AssetDatabase.FindAssets)"]
G --> H{"zero matches?"}
H -- yes --> I["Warn and keep prefabPath as original"]
H -- no --> J{"multiple matches?"}
J -- yes --> K["Warn and keep prefabPath as original"]
J -- no --> L["Set prefabPath to unique prefab path"]
F -- no --> M{"extension != .prefab"}
M -- yes --> N["Search for asset file by file name"]
N --> O{"zero matches?"}
O -- yes --> P["Return ErrorResponse("Asset file not found")"]
O -- no --> Q{"multiple matches?"}
Q -- yes --> R["Return ErrorResponse("Multiple assets found")"]
Q -- no --> S["Set prefabPath to unique asset path"]
E -- yes --> T{"extension is null or empty?"}
T -- yes --> U["Warn and append .prefab to prefabPath"]
T -- no --> V["Leave prefabPath unchanged"]
I --> W
K --> W
L --> W
S --> W
U --> W
V --> W
W["LoadAssetAtPath<GameObject>(prefabPath)"] --> X{"prefabAsset is not null?"}
X -- yes --> Y["Instantiate prefab and continue"]
X -- no --> AA["Return ErrorResponse("Asset not found or not a GameObject at path")"]
Z --> End["Continue with non-prefab creation path"]
Y --> End
P --> End
R --> End
AA --> End
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
|
Caution Review failedThe pull request is closed. 📝 WalkthroughWalkthroughTwo changes improve command execution reliability and prefab resolution: BatchExecute adds a helper to dynamically detect command success from varied result shapes and conditionally exit early when failFast is enabled, while GameObjectCreate adds extension handling and AssetDatabase name-based prefab resolution with immediate error responses for missing assets. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
✨ Finishing touches
📜 Recent review detailsConfiguration used: defaults Review profile: CHILL Plan: Pro 📒 Files selected for processing (2)
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey - I've left some high level feedback:
- In
DetermineCallSucceeded, theresult is JToken tokenbranch can throw for non-container tokens (e.g.,JValue) when indexing withtoken["success"]; consider restricting this path toJObject/JContaineror checkingtoken.Type == JTokenType.Objectbefore accessing by key. DetermineCallSucceededdefaults totruefornullor unrecognized result types, which may mask failures; consider either defaulting tofalseor at least logging when the method falls back to this default so unexpected result shapes are visible.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- In `DetermineCallSucceeded`, the `result is JToken token` branch can throw for non-container tokens (e.g., `JValue`) when indexing with `token["success"]`; consider restricting this path to `JObject`/`JContainer` or checking `token.Type == JTokenType.Object` before accessing by key.
- `DetermineCallSucceeded` defaults to `true` for `null` or unrecognized result types, which may mask failures; consider either defaulting to `false` or at least logging when the method falls back to this default so unexpected result shapes are visible.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
上游變更 (v7.0.0 → v9.0.3): - GameObject 工具集重構 (CoplayDev#518) - VFX 管理功能 (CoplayDev#520) - 批次執行錯誤處理改進 (CoplayDev#531) - Windows 長路徑問題修復 (CoplayDev#534) - HTTP/Stdio 傳輸 UX 改進 (CoplayDev#530) - LLM 工具註解功能 (CoplayDev#480) 衝突解決: - modify/delete:接受刪除(架構已重構) - content:接受 v9.0.3 版本(2020 相容性修正將另行處理)
…d fail-fast support
feat(game_object_create): enhance asset
Summary by Sourcery
Improve batch command execution error handling and enhance game object creation prefab/asset resolution.
New Features:
Bug Fixes:
Enhancements:
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.