Skip to content
This repository was archived by the owner on Aug 30, 2025. It is now read-only.

Email transformation crashes when maxLength is too low and preserveDomain is true #3540

@agedemenli

Description

@agedemenli

Bug description

Generating a fullname email and preserving the domain with a low maxLength value causing crash.

transformEmail calculates maxNameLength by substracting the domain length from maxLength.
https://github.com/nucleuscloud/neosync/blob/main/worker/pkg/benthos/transformers/transform_email.go#L326

Then calls generateNameForEmail if the email type is fullname, passing a negative value as maxNameLength if preserve_domain is true, and the domain is longer than maxLength.
https://github.com/nucleuscloud/neosync/blob/main/worker/pkg/benthos/transformers/transform_email.go#L326

Then it crashes trying to generate a random string with negative size.
https://github.com/nucleuscloud/neosync/blob/main/worker/pkg/benthos/transformers/generate_email.go#L217

How to reproduce

  1. Set preserveDomain: true, maxLength: 11, emailType: 'fullname'
  2. Pass anyname@hotmail.com as input.
  3. GetRandomCharacterString will crash because of a negative value for parameter size.

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