Skip to content

Fix remote commend error return issue#2120

Merged
cb-github-robot merged 1 commit intocloud-barista:mainfrom
seokho-son:main
Aug 28, 2025
Merged

Fix remote commend error return issue#2120
cb-github-robot merged 1 commit intocloud-barista:mainfrom
seokho-son:main

Conversation

@seokho-son
Copy link
Copy Markdown
Member

  • change error return to string return for API clients

Signed-off-by: Seokho Son <shsongist@gmail.com>
Copilot AI review requested due to automatic review settings August 28, 2025 02:49
@seokho-son seokho-son requested a review from yunkon-kim as a code owner August 28, 2025 02:49
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 SshCmdResultForAPI and MciSshCmdResultForAPI with 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)

Copy link

Copilot AI Aug 28, 2025

Choose a reason for hiding this comment

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

[nitpick] Empty line at end of function should be removed for cleaner code formatting.

Suggested change

Copilot uses AI. Check for mistakes.

// Return the result
return clientManager.EndRequestWithLog(c, err, result)
return clientManager.EndRequestWithLog(c, nil, result)
Copy link

Copilot AI Aug 28, 2025

Choose a reason for hiding this comment

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

The error parameter is hardcoded to nil but should use the actual err variable to properly handle any errors that occurred during file transfer.

Suggested change
return clientManager.EndRequestWithLog(c, nil, result)
return clientManager.EndRequestWithLog(c, err, result)

Copilot uses AI. Check for mistakes.
@seokho-son
Copy link
Copy Markdown
Member Author

/approve

@github-actions github-actions bot added the approved This PR is approved and will be merged soon. label Aug 28, 2025
@cb-github-robot cb-github-robot merged commit 945a1e4 into cloud-barista:main Aug 28, 2025
4 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved This PR is approved and will be merged soon.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants