floci-io/floci · error · CoercingParseValueException

Invalid AWSEmail: {}

Error message

Invalid AWSEmail: {}

What it means

Thrown by the AWSEmail scalar's parseValue when the string does not match the RFC-style email regex ^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$. The scalar validates syntactic shape only: local part, @, domain with dot, and a TLD of at least two letters.

Source

Thrown at src/main/java/io/github/hectorvent/floci/services/appsync/graphql/scalars/AppSyncScalars.java:178

            }
        })
        .build();

    private static final Pattern EMAIL_PATTERN = Pattern.compile("^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$");

    public static final GraphQLScalarType AWS_EMAIL = GraphQLScalarType.newScalar()
        .name("AWSEmail")
        .description("An RFC 5322 email address")
        .coercing(new Coercing<String, String>() {
            @Override
            public String serialize(Object dataFetcherResult) {
                return dataFetcherResult != null ? dataFetcherResult.toString() : null;
            }
            @Override
            public String parseValue(Object input) {
                String str = input.toString();
                if (!EMAIL_PATTERN.matcher(str).matches())
                    throw new CoercingParseValueException("Invalid AWSEmail: " + str);
                return str;
            }
            @Override
            public String parseLiteral(Object input) {
                if (!(input instanceof StringValue sv)) return null;
                return parseValue(sv.getValue());
            }
        })
        .build();

    public static final GraphQLScalarType AWS_URL = GraphQLScalarType.newScalar()
        .name("AWSURL")
        .description("A valid URL")
        .coercing(new Coercing<String, String>() {
            @Override
            public String serialize(Object dataFetcherResult) {
                return dataFetcherResult != null ? dataFetcherResult.toString() : null;
            }

View on GitHub (pinned to 62ff490619)

Solutions

  1. Validate (and trim) client-side before the request with an RFC 5322 or HTML5 email regex
  2. Reject empty strings early with your own error message
  3. For non-ASCII/international addresses, convert to punycode (IDN.toASCII) before sending
  4. Use realistic fixtures like user@example.com in tests

Example fix

// before
variables.put("email", "  user@example "); // fails pattern

// after
String email = raw.trim();
if (!email.matches("^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$")) throw new IllegalArgumentException("bad email");
variables.put("email", email);
Defensive patterns

Strategy: validation

Validate before calling

private static final Pattern EMAIL = Pattern.compile("^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$");
String email = raw == null ? null : raw.trim();
if (email != null && !EMAIL.matcher(email).matches()) throw new IllegalArgumentException("invalid email");

Type guard

const isAwsEmail = (s: string): boolean => /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/.test(s.trim());

Try / catch

catch (CoercingParseValueException e) { // invalid input: mark the form field, do not retry as-is }

Prevention

When it happens

Trigger: A GraphQL request sends "user@@example.com", "user@example" (no TLD), "user @example.com" (space), "user@example.c" (single-letter TLD), or an empty string as an AWSEmail variable.

Common situations: Missing client-side trim/validation before submit; copy-pasted addresses with trailing spaces or newlines; internationalized domains rendered with unicode (the pattern is ASCII-only); test fixtures using "not-an-email" or "a@b" placeholders.

Related errors


AI-assisted analysis of floci-io/floci@62ff490619 (2026-08-14). Data as JSON: /api/errors/8d65d2ca36faf1a9. Report an issue: GitHub.