unisonweb / unison

A friendly programming language from the future
https://unison-lang.org
Other
5.68k stars 265 forks source link

Reduce footguns around release branch cloning #4805

Open pchiusano opened 4 months ago

pchiusano commented 4 months ago

Currenly if you clone @someone/someproject/releases/0.1.0, then branch, do stuff, then attempt to push you get a cryptic error: https://discord.com/channels/862108724948500490/1219262772299431946/1219262957347930122

@runarorama/timers/upgradeBase> push

  Uploaded 1 entities.

  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
                , baseUrlHost = "api.unison-lang.org"
                , baseUrlPort = 443
                , baseUrlPath = ""
                }
            , "/ucm/v1/projects/create-project-branch"
            )
        , requestQueryString = fromList []
        , requestBody = Just
            ( ()
            , application/json;charset=utf-8
            )
        , requestAccept = fromList
            [ application/json;charset=utf-8
            , application/json
            ]
        , requestHeaders = fromList []
        , requestHttpVersion = HTTP/1.1
        , requestMethod = "POST"
        }

  Here is the full response.

    Response
        { responseStatusCode = Status
            { statusCode = 400
            , statusMessage = "Invalid Parameter"
            }
        , responseHeaders = fromList
            [
                ( "Server"
                , "nginx/1.24.0"
                )
            ,
                ( "Date"
                , "Mon, 18 Mar 2024 12:34:17 GMT"
                )
            ,
                ( "Transfer-Encoding"
                , "chunked"
                )
            ,
                ( "Connection"
                , "keep-alive"
                )
            ,
                ( "X-RequestID"
                , "75f4b250-44a5-4493-820d-6060a705d73b"
                )
            ]
        , responseHttpVersion = HTTP/1.1
        , responseBody = "Unable to parse parameter merge-target-branch-id, Could not parse 'R-0b04980c-de49-4497-9e4b-8c32337ba910', expected B-<uu
id>"
        }

We are guessing that the merge-target is the original branch, which is a release branch, which Share is not expecting. How should we handle this better?

  1. Share backend probably shouldn't bomb, should just reply with a nicer error which ucm can report. Or it can simply ignore the UCM-provided default merge target in this situation and make it main.
  2. UCM should probably not allow changes to release branches and it should warn you if you're making a branch off of a release branch. "NOTE: You're branching off of a release, instead of a branch with history. This isn't typically what you want."

Or something.

hojberg commented 4 months ago

side note: the error could just be

Oops, looks like something isn't quite right. 
I received an unexpected error response from Share (HTTP Status 400, Invalid parameter).

Or similar. The dump of the HTTP Request and Response isn't useful to the user as they have no power to change those.

aryairani commented 1 month ago
  1. Is no good as long as we continue to squash releases.