sorenlouv / backport

A simple CLI tool that automates the process of backporting commits on a GitHub repo
https://github.com/sqren/backport/blob/main/docs/config-file-options.md
Apache License 2.0
241 stars 57 forks source link

Unhandled Error in Backport CLI - Code 128 "Not a valid commit name" #433

Closed jeramysoucy closed 1 year ago

jeramysoucy commented 1 year ago

Just ran into an issue when trying to start a manual backport on 137232. I get this: Backporting to 8.3: ✔ Pulling latest changes ✖ Cherry-picking: Update simple-git 1.116.0 -> 3.10.0 (#137232) An unhandled error occurred while backporting commit. Please see the logs for details

Backporting to 7.17: ✔ Pulling latest changes ✖ Cherry-picking: Update simple-git 1.116.0 -> 3.10.0 (#137232) An unhandled error occurred while backporting commit. Please see the logs for details

The end of the backport.debug.log:

{
  "level": "info",
  "message": "Results",
  "metadata": {
    "0": {
      "error": {
        "context": {
          "cmdArgs": [
            "merge-base",
            "--is-ancestor",
            "dcc4ad744b484778ffb133214a641837b6314fef",
            "HEAD"
          ],
          "code": 128,
          "stderr": "fatal: Not a valid commit name dcc4ad744b484778ffb133214a641837b6314fef\n",
          "stdout": ""
        },
        "name": "SpawnError"
      },
      "status": "unhandled-error",
      "targetBranch": "8.3"
    },
    "1": {
      "error": {
        "context": {
          "cmdArgs": [
            "merge-base",
            "--is-ancestor",
            "dcc4ad744b484778ffb133214a641837b6314fef",
            "HEAD"
          ],
          "code": 128,
          "stderr": "fatal: Not a valid commit name dcc4ad744b484778ffb133214a641837b6314fef\n",
          "stdout": ""
        },
        "name": "SpawnError"
      },
      "status": "unhandled-error",
      "targetBranch": "7.17"
    }
  },
  "timestamp": "2022-07-29 09:12:20"
}

{
  "level": "verbose",
  "message": "Error when running command: \"git merge-base --is-ancestor 6e920d43e107339f4cda74e9753bad215dcbce34 HEAD\" Code: 1, Args: \"merge-base --is-ancestor 6e920d43e107339f4cda74e9753bad215dcbce34 HEAD\", Message: ",
  "metadata": {
    "context": {
      "cmdArgs": [
        "merge-base",
        "--is-ancestor",
        "6e920d43e107339f4cda74e9753bad215dcbce34",
        "HEAD"
      ],
      "code": 1,
      "stderr": "",
      "stdout": ""
    },
    "name": "SpawnError",
    "stack": "SpawnError: Code: 1, Args: \"merge-base --is-ancestor 6e920d43e107339f4cda74e9753bad215dcbce34 HEAD\", Message: \n    at ChildProcess.<anonymous> (/Users/jeramysoucy/GitHub/kibana-3/node_modules/backport/dist/lib/child-process-promisified.js:43:29)\n    at ChildProcess.emit (node:events:527:28)\n    at maybeClose (node:internal/child_process:1092:16)\n    at Process.ChildProcess._handle.onexit (node:internal/child_process:302:5)"
  },
  "timestamp": "2022-07-29 09:12:21"
}
sorenlouv commented 1 year ago

I was not able to reproduce but I've changed the error handling so that errors for this codepath will no longer be thrown but instead caught and logged:

https://github.com/sqren/backport/commit/ed657b009818668547d9b7ca08097ed64f794178#diff-12c14148d3a2b1e09d98f563671997a0d912b6d90d9816b50f92010eaebbe116

This new behaviour is acceptable since any errors thrown in this codepath must not affect the actual backporting.