Fix remote commend error return issue#2120
Fix remote commend error return issue#2120cb-github-robot merged 1 commit intocloud-barista:mainfrom
Conversation
seokho-son
commented
Aug 28, 2025
- change error return to string return for API clients
Signed-off-by: Seokho Son <shsongist@gmail.com>
There was a problem hiding this comment.
Pull Request Overview
This PR introduces a new API-friendly data structure for SSH command results by converting error objects to string representations for proper JSON serialization. The change ensures API clients receive properly serialized error information instead of potentially problematic error objects.
- Adds new model types
SshCmdResultForAPIandMciSshCmdResultForAPIwith string error fields - Updates REST endpoints to use the new API-friendly result structures
- Implements conversion function to transform internal results to API format
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/interface/rest/server/infra/remoteCommand.go | Adds conversion function and updates endpoints to use API-friendly result format |
| src/core/model/mci.go | Defines new API-friendly data structures with string error field |
| src/core/infra/remoteCommand.go | Adds VM status validation for SSH commands and file transfers |
| src/interface/rest/docs/. | Updates Swagger documentation to reflect new API response models |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| common.PrintJsonPretty(result) | ||
|
|
||
| return c.JSON(http.StatusOK, result) | ||
|
|
There was a problem hiding this comment.
[nitpick] Empty line at end of function should be removed for cleaner code formatting.
|
|
||
| // Return the result | ||
| return clientManager.EndRequestWithLog(c, err, result) | ||
| return clientManager.EndRequestWithLog(c, nil, result) |
There was a problem hiding this comment.
The error parameter is hardcoded to nil but should use the actual err variable to properly handle any errors that occurred during file transfer.
| return clientManager.EndRequestWithLog(c, nil, result) | |
| return clientManager.EndRequestWithLog(c, err, result) |
|
/approve |