unison icon indicating copy to clipboard operation
unison copied to clipboard

`lib.install invalid/project/reference` should have a better error message

Open stew opened this issue 7 months ago • 0 comments

What's the message you're seeing?

When I mistakenly type lib.intsall unison/cloud instead of lib.install @unison/cloud I get this error message:

  Oops, I received an unexpected status code from the server.
  
  Here is the request.
  
    Request
        { requestPath =
            ( BaseUrl
                { baseUrlScheme = Https
                , baseUrlHost = "api.unison-lang.org"
                , baseUrlPort = 443
                , baseUrlPath = ""
                }
            , "/ucm/v1/projects/project"
            )
        , requestQueryString = fromList
            [
                ( "name"
                , Just "unison"
                )
            ]
        , requestBody = Nothing
        , requestAccept = fromList
            [ application/json;charset=utf-8
            , application/json
            ]
        , requestHeaders = fromList []
        , requestHttpVersion = HTTP/1.1
        , requestMethod = "GET"
        }
  
  Here is the full response.
  
    Response
        { responseStatusCode = Status
            { statusCode = 400
            , statusMessage = "Invalid Parameter"
            }
        , responseHeaders = fromList
            [
                ( "Server"
                , "nginx/1.24.0"
                )
            ,
                ( "Date"
                , "Wed, 10 Jul 2024 21:14:51 GMT"
                )
            ,
                ( "Transfer-Encoding"
                , "chunked"
                )
            ,
                ( "Connection"
                , "keep-alive"
                )
            ,
                ( "X-RequestID"
                , "1914775a-03ad-4109-ae64-ef3545658e0e"
                )
            ]
        , responseHttpVersion = HTTP/1.1
        , responseBody = "Unable to parse parameter name, Project shorthand must be of the form @user/project"
        }

What would a better version look like?

This error would ideally be caught in the client and not make an invalid request to the server.

Invalid project: unison/cloud.

Perhaps you meant @unison/cloud
  • ucm --version: unison version: 60bb91a (built on 2024-07-05)
  • OS/Architecture: debian bookwork amd64

stew avatar Jul 10 '24 21:07 stew