Skip to content

[bug] towncrier create allows fragment creation with invalid filenames #733

@webknjaz

Description

@webknjaz

So in sanitizers/chronographer-github-app#44, @praiskup reported $sbj as follows:

I opened this, because we hit a real-life issue with towncrier:

$ towncrier create foo.bar.baz.config
Created news fragment at /home/praiskup/rh/projects/mock/mock/releng/release-notes-next/foo.bar.baz.config

At least we were allowed to create such file, I assumed that it "is a correct snippet" then, and I'd expect that the action accepts it as well. But is this a bug of towncrier create?

This created a false sense of implied correctness, but I'm sure that towncrier build will get confused trying to identify this file and assign identifier+category.

https://towncrier.readthedocs.io/en/stable/tutorial.html#creating-news-fragments and https://towncrier.readthedocs.io/en/stable/cli.html#towncrier-create only roughly mentions what the shape of the filename is expected to look like.
From my earlier experience and reading the source code in the past, I know that what works is <number-ref>.<category>, <number-ref>.<category>.<discardable-suffix>, <number-ref>.<category>.<number>, <number-ref>.<category>.<number>.<discardable-suffix>, +<discardable-ref>.<category>, +<discardable-ref>.<category>.<discardable-suffix>, +<discardable-ref>.<category>.<number>, +<discardable-ref>.<category>.<number>.<discardable-suffix>.

But it doesn't look clear to a casual reader that neither <number-ref>, nor <discardable-ref> is allowed to contain a period.
So I imagine this could be turned into two issues:

  • Make the create and build subcommands coherent, interpreting the file names consistently (with proper input validation).
  • Ensure the expectations are spelled out in the docs.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions