SpaceTradersAPI / issues-and-suggestions

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Jettison successful but throws conflict for remaining quantity <= 1

jadlers opened this issue · comments

User "notcaffeinefree" posted an issue on Discord. Using the jettison endpoint PUT /users/:user/ships/:shipId/jettison did successfully jettison but responded with a 409 Conflict status code.

It seems like the issue is when the remaining quantity is 1 or less. See example:

$ http PUT :8080/users/$username/ships/$shipId/jettison token==$token  good=FUEL  quantity=2

HTTP/1.1 200 OK
{
    "good": "FUEL",
    "quantityRemaining": 8,
    "shipId": "ckmmdp3uv0066emop88z8j9ab"
}

The ship now has 8 FUEL. Trying to jettison 7 results in a conflict:

$ http PUT :8080/users/$username/ships/$shipId/jettison token==$token  good=FUEL  quantity=7

HTTP/1.1 409 Conflict
{
    "error": {
        "code": 409,
        "message": "Failed to process jettison request due to a conflict. You may be sending the same request multiple times. Please try again later if necessary."
    }
}

List ship afterwards:

$ http :8080/users/$username/ships/$shipId token==$token

HTTP/1.1 200 OK
{
    "ship": {
        "cargo": [
            {
                "good": "FUEL",
                "quantity": 1,
                "totalVolume": 1
            }
        ],
        "class": "MK-I",
        "id": "ckmmdp3uv0066emop88z8j9ab",
        "location": "OE-PM-TR",
        "manufacturer": "Jackshaw",
        "maxCargo": 100,
        "plating": 5,
        "spaceAvailable": 99,
        "speed": 2,
        "type": "JW-MK-I",
        "weapons": 5,
        "x": 23,
        "y": -28
    }
}