gavinr / github-csv-tools

Import and export GitHub issues via CSV
https://npmjs.com/github-csv-tools
MIT License
650 stars 116 forks source link

Fix import of issues without body message #115

Open ssinhaleite opened 8 months ago

ssinhaleite commented 8 months ago

The CSV import threw an error when an issue didn't have a body defined. Since it is a good practice to have a body defined, in the case of importing issues, we duplicate the title into the body. While this doesn't clarify the issue, it highlights the problem and still imports the issue.

Another option would be to remove the verification that the body is empty whatsoever, and if a body column exists, just add it the way it is, even if empty.

gavinr commented 8 months ago

Hi @ssinhaleite, thanks for the PR.

The CSV import threw an error when an issue didn't have a body defined

Can you tell me more about the error that you received? Was it from this library or from the GitHub API? Can you provide an example CSV that causes the error to happen?

Thanks!

ssinhaleite commented 8 months ago

Hi @gavinr! I've just added a CSV example file that would raise an error.

It generates the following error message:

Error
RequestError [HttpError]: Validation Failed: {"resource":"Issue","code":"missing_field","field":"body"}
    at /home/vleite/.nvm/versions/node/v20.10.0/lib/node_modules/github-csv-tools/node_modules/@octokit/request/dist-node/index.js:122:21
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

  ...
gavinr commented 8 months ago

Thanks for providing the example.

As a user, if I'm trying to import your example: image

I would NOT expect the issue title to be in the body of the first issue... I would actually expect the body to be empty.

In the GitHub web UI, you CAN create an issue with an empty body.

So I think we need to do some research to figure out how to create an issue with an empty body in these cases.

If you'd like to update your PR to do that, please do. Otherwise we could close this and open an issue for discussion.

ssinhaleite commented 8 months ago

Hi @gavinr,

Yes, indeed it is possible to create an issue without body content in the web interface, and replicating the title in the body of an issue is not the ideal case.

However, although the REST API (https://docs.github.com/en/rest/issues/issues?apiVersion=2022-11-28#create-an-issue) says the title is the only required field, I had tried to create an issue with the title and without a body, and I keep getting the error: 422 - "missing field: body". This error contains the same structure as if I try to create an issue with a body and no title, which indicates the body is being considered a required field. The error doesn't appear if I remove any other field.

I understand if this is not a solution for you. I forked the project and added this solution to my fork of your code. At least I could import all my issues.

Thank you for your consideration.