Skip to content

changie still produces a changelog file on error in batch command #714

@Magic-Mayo

Description

@Magic-Mayo

Thanks for submitting a bug report, please fill in the following details.

Description
I recently had a misuse of a tempate function in my changie.yaml which led to an expected error when running changie batch auto. The unexpected part was that it still produced a partial changelog. The specific issue I had was only sending in one arg to the customs function instead of two. This led to changie stopping processing but not before it wrote to the next version's changelog "fragment" (not sure how you refer to it internally 😅 ) that lives under the .changes directory.

I understand how things are happening in code and I know this was user error but it might be good to save the user from their own mistakes sometimes. I could see this happening and being ignored or not seen before running changie merge and a release being cut before it's ever noticed...then there's larger issues to overcome. This is just one issue I ran into but if templates are being written and not cleaned up on error I can see it happening for different types of user errors.

Reproduction Steps
Steps to reproduce the behavior:

  1. Set the changeFormat key in changie.yaml to intentionally misuse the customs template function so it errors: {{customs .Changes}}
  2. Run changie new and create a new change for one of the projects
  3. Run changie batch auto
  4. See error

What happened
An error like:

Error: template: {{customs .Changes}}:1:2: executing "{{customs .Changes}}" at <customs>: wrong number of args for customs: want 2 got 1

as well as a versioned changelog file that looked like

## 1.5.0 - 2024-09-09
### Feature

Expected behavior
An error but nothing written to any files or files cleaned up before the process exits.

Additional context

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions