Skip to content

Conversation

@kpatl1
Copy link
Collaborator

@kpatl1 kpatl1 commented Oct 16, 2025

Summary:

I implemented error handling for drag-and-drop file operations to the SAS Server by adding a try-catch block to RestServerAdapter.moveItem(). The Viya server's updateFileOrDirectoryOnSystem API already validates for duplicate file names by default and returns an error if a file with the same name exists at the destination. The try-catch properly catches these server errors and returns undefined, allowing the UI to display an error message to the user. This fix makes RestServerAdapter consistent with the error handling patterns in RestContentAdapter and ItcServerAdapter, and relies on server-side validation as the single source of truth rather than unreliable client-side checks.

Testing:
Made a new file with the same name as one within a folder on a SAS Server. Then, I dragged the root file into the folder and it prevented me from moving it.

Fixes #1578

TODOs:

  • Add any supporting documentation and (optionally) update CHANGELOG.md

@kpatl1 kpatl1 requested a review from scnwwu October 16, 2025 19:15
@kpatl1 kpatl1 changed the title feat(ContentNavigator): added name checking for duplicates on drag and drop fix(ContentNavigator): added name checking for duplicates on drag and drop Oct 16, 2025
@kpatl1 kpatl1 marked this pull request as ready for review October 16, 2025 19:21
@scnwwu
Copy link
Contributor

scnwwu commented Oct 20, 2025

I think the check should NOT be done by client. Client side check is not reliable as it's async. The file system on server may changed after your getChildren call. The server should already report error for this situation. The client just needs to display the error to user. It's not limited to name collision but whatever errors failed the operation.

As #1578 mentioned, the SAS Content pane already report error.
The UI is shared:
https://github.com/sassoftware/vscode-sas-extension/blob/main/client/src/components/ContentNavigator/ContentDataProvider.ts#L707

Both RestContentAdapter and ItcServerAdapter return falsy on error.
https://github.com/sassoftware/vscode-sas-extension/blob/main/client/src/connection/rest/RestContentAdapter.ts#L225
https://github.com/sassoftware/vscode-sas-extension/blob/main/client/src/connection/itc/ItcServerAdapter.ts#L300

So I guess RestServerAdapter should do similar.
https://github.com/sassoftware/vscode-sas-extension/blob/main/client/src/connection/rest/RestServerAdapter.ts#L450

@kpatl1
Copy link
Collaborator Author

kpatl1 commented Oct 22, 2025

That makes more sense. I have added the changes in to catch the error from the server side.

@scnwwu scnwwu added this to the 1.18.0 milestone Oct 23, 2025
@enzhihpp enzhihpp assigned Zhirong2022 and unassigned enzhihpp Oct 23, 2025
@Zhirong2022 Zhirong2022 added testing Test the pull requests and removed verification-needed labels Oct 23, 2025
@Zhirong2022
Copy link

Zhirong2022 commented Oct 28, 2025

Error message pops for duplicates on drag and drop.
dragAndDrop

@Zhirong2022 Zhirong2022 added testing-complete Complete the pull requests testing and removed testing Test the pull requests labels Oct 28, 2025
@kpatl1 kpatl1 merged commit 25a234d into main Oct 29, 2025
2 checks passed
@kpatl1 kpatl1 deleted the bug/kpatl1-1578 branch October 29, 2025 22:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

testing-complete Complete the pull requests testing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

There is no error validation if trying to drag and drop a file to a new position which contains a file with the same name on SAS Server

5 participants