floci-io/floci · error · CoercingParseValueException

Invalid AWSURL: {}

Error message

Invalid AWSURL: {}

What it means

Thrown by the AWSURL scalar's parseValue when the string cannot be converted to an absolute URL. The coercion calls URI.create(str).toURL(), which requires a syntactically valid URI with a known protocol handler; relative URLs, missing schemes, or malformed URIs throw and produce this error.

Source

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

            }
        })
        .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;
            }
            @Override
            public String parseValue(Object input) {
                String str = input.toString();
                try {
                    URI.create(str).toURL();
                } catch (Exception e) {
                    throw new CoercingParseValueException("Invalid AWSURL: " + str);
                }
                return str;
            }
            @Override
            public String parseLiteral(Object input) {
                if (!(input instanceof StringValue sv)) return null;
                return parseValue(sv.getValue());
            }
        })
        .build();

    private static final Pattern PHONE_PATTERN = Pattern.compile("^\\+[1-9]\\d{1,14}$");

    public static final GraphQLScalarType AWS_PHONE = GraphQLScalarType.newScalar()
        .name("AWSPhone")
        .description("An E.164 phone number")
        .coercing(new Coercing<String, String>() {
            @Override

View on GitHub (pinned to 62ff490619)

Solutions

  1. Always include the scheme: https://example.com/path
  2. Normalize user input: if (!url.matches("^https?://.*")) url = "https://" + url; then trim
  3. Validate client-side with new URI(url).toURL() in a try-catch before sending
  4. For relative paths, store them in a plain String field, not AWSURL

Example fix

// before
String url = "example.com/assets/logo.png"; // no scheme -> throws

// after
String url = "https://example.com/assets/logo.png";
Defensive patterns

Strategy: validation

Validate before calling

static String normalizeUrl(String raw) {
    String u = raw.trim();
    if (!u.matches("(?i)^[a-z][a-z0-9+.-]*:.*")) u = "https://" + u;
    URI.create(u).toURL(); // throws early with a clearer stack
    return u;
}

Type guard

const isAwsUrl = (s: string): boolean => { try { new URL(s.trim()); return true; } catch { return false; } };

Try / catch

catch (CoercingParseValueException e) { // ask user for full URL including scheme; auto-prepend https:// then retry }

Prevention

When it happens

Trigger: A GraphQL request sends "example.com/path" (no scheme), "http//example.com" (malformed), "my app://x" (illegal space), or a relative path "/callback" as an AWSURL variable.

Common situations: Storing user-entered links without requiring the https:// prefix; concatenating a base URL and path but forgetting the scheme; custom app schemes with invalid characters; whitespace or unicode sneaking into the URL; config values intended to be relative paths placed in URL fields.

Related errors


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