Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 517621

Summary: Stash REST API gives ambiguous errors when handling DELETE requests
Product: [ECD] Orion Reporter: Remy Suen <remy.suen>
Component: NodeAssignee: Remy Suen <remy.suen>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3    
Version: unspecified   
Target Milestone: 15.0   
Hardware: All   
OS: All   
Whiteboard:

Description Remy Suen CLA 2017-06-01 05:03:10 EDT
1. Launch your server pointing at Git repository. So if you have /blah/blah/.git, then start Orion pointing at /blah/blah

$ node server.js -w /blah/blah/

2. 

$ curl -X DELETE "http://localhost:8081/gitapi/stash/file/orionode"
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100    58  100    58    0     0   1870      0 --:--:-- --:--:-- --:--:--  1870{"Severity":"Error","Message":"Number index is required."}

$ curl -X DELETE "http://localhost:8081/gitapi/stash/abc/file/orionode"
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100    58  100    58    0     0   3866      0 --:--:-- --:--:-- --:--:-- 58000{"Severity":"Error","Message":"Number index is required."}
Comment 1 Remy Suen CLA 2017-06-01 05:08:45 EDT
I forgot to mention that the /blah/blah repository should have nothing in the stash.

If there is something in the stash and you give it an incorrect stash revision SHA hash, the same error will occur.

$ curl -X DELETE "http://localhost:8081/gitapi/stash/abc/file/orionode"
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100    58  100    58    0     0   1870      0 --:--:-- --:--:-- --:--:--  3625{"Severity":"Error","Message":"Number index is required."}
Comment 2 Remy Suen CLA 2017-06-01 05:36:01 EDT
First pass pushed to master.

-try to drop the stash when it is empty
-try to drop an invalid stash revision when the stash is not empty

{"Severity":"Error","Message":"Failed to drop stashed changes due to an empty stash."}

-try to drop an invalid stash revision when the stash is not empty

{"Severity":"Error","Message":"Invalid stash reference abc."}

https://github.com/eclipse/orion.client/commit/2cee3036bd2cd6e1d084752b3f16097b6995553c
Comment 3 Remy Suen CLA 2017-06-01 06:00:31 EDT
1. Stash something so that your stash is non-empty.
2. Try to delete everything from your stash.

$ curl -X DELETE "http://localhost:8081/gitapi/stash/file/orionode"
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100    82  100    82    0     0   1051      0 --:--:-- --:--:-- --:--:--  1322{"Severity":"Error","Message":"No stashed state at position 18446744073709551615"}
Comment 4 Remy Suen CLA 2017-06-01 06:15:26 EDT
Second pass pushed to master. This fixes the scenario described in comment 3.

https://github.com/eclipse/orion.client/commit/e3c979fb639caee4f5cbca37beb52bc69d85f68b