Skip to content

--size 1 fails validation with "Padding must be less than half the size" even at the default padding of 0; --size 3 --padding 1 is rejected though it works #122

Description

@matt-edmondson

What's wrong

The padding check uses integer division against the requested size, so it rejects inputs that the processing pipeline handles fine.

Where

IconHelper/Arguments.cs:53:

else if (Size > 0 && Padding >= Size / 2)
{
    errors.Add("Padding must be less than half the size of the image.");
}

The pipeline's own bound is EffectivePadding (IconHelper/IconHelper.cs:403), which accepts padding up to (size - 1) / 2.

Failure scenarios

  • --size 1 with the default padding: Size / 2 == 0, so 0 >= 0 and Validate() fails with the padding message, even though no padding was given. A throwaway test with Size = 1 and valid input/output directories confirmed Validate() == false. The documented size rule is only Size <= 0 → error.
  • --size 3 --padding 1: 1 >= 1 is rejected, yet EffectivePadding allows 1 for size 3 and leaves a 1-pixel image.

Suggested fix

  • Validate with the same bound the pipeline uses: Padding > (Size - 1) / 2 → error, which is equivalent to 2 * Padding >= Size.
  • Update the message to match.
  • Add Arguments tests for Size = 1, Padding = 0 (valid), Size = 3, Padding = 1 (valid) and Size = 4, Padding = 2 (invalid).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions