apache/beam · error · IllegalArgumentException

Service endpoint must be a URI, got

Error message

Service endpoint must be a URI, got: %s

What it means

KinesisReadSchemaTransformProvider.expand parses config.getServiceEndpoint() as a java.net.URI. If the string is not valid URI syntax, the URISyntaxException is wrapped into an IllegalArgumentException with the offending value. The endpoint is optional but, when provided, must be a well-formed URI (e.g. https://kinesis.us-east-1.amazonaws.com).

Solutions

  1. Add a scheme to the endpoint, e.g. https://host:port
  2. Validate the endpoint string with new URI(...) in config prep before submitting the pipeline
  3. If using Kinesalite/localstack use 'http://localhost:4566'
  4. Remove the service_endpoint key if you intend to use the default AWS endpoint

Example fix

// before
service_endpoint: kinesis.us-east-1.amazonaws.com
// after
service_endpoint: https://kinesis.us-east-1.amazonaws.com
Defensive patterns

Strategy: validation

Validate before calling

URI ep;
try { ep = new URI(config.getServiceEndpoint()); } catch (URISyntaxException e) { throw new IllegalArgumentException("bad service_endpoint", e); }

Type guard

boolean validEndpoint(String s) { try { new URI(s); return true; } catch (Exception e) { return false; } }

Try / catch

try { expand(cfg); } catch (IllegalArgumentException e) { fix endpoint syntax in pipeline options; resubmit; }

Prevention

When it happens

Trigger: Setting service_endpoint in a YAML/schema-transform pipeline to something like 'kinesis.us-east-1.amazonaws.com' (missing scheme) or a string with spaces/illegal characters.

Common situations: Copy-pasting an endpoint host without https://; trailing slashes or typos; using an environment placeholder that didn't expand; local Kinesis (Kinesalite) endpoints without scheme.

Understand the failure class

Background: "Invalid URL" errors: why new URL(), URI.parse, and reqwest::Url reject your string — missing scheme, whitespace, and bad path format — this error's family across 39 libraries.

Related errors


AI-assisted analysis of apache/beam@12126d8942 (2026-09-13). Data as JSON: /api/errors/e703bce6c5ca635b. Report an issue: GitHub.

Appendix: source

Thrown at sdks/java/io/amazon-web-services2/src/main/java/org/apache/beam/sdk/io/aws2/kinesis/KinesisReadSchemaTransformProvider.java:217

    }

    @Override
    public PCollectionRowTuple expand(PCollectionRowTuple input) {
      Preconditions.checkState(
          input.getAll().isEmpty(),
          "Expected zero input PCollections for this source, but found: %s",
          input.getAll().keySet());

      AwsBasicCredentials creds =
          AwsBasicCredentials.create(config.getAwsAccessKey(), config.getAwsSecretKey());
      StaticCredentialsProvider provider = StaticCredentialsProvider.create(creds);

      @Nullable URI endpoint = null;
      if (config.getServiceEndpoint() != null) {
        try {
          endpoint = new URI(config.getServiceEndpoint());
        } catch (URISyntaxException ex) {
          throw new IllegalArgumentException(
              String.format("Service endpoint must be a URI, got: %s", config.getServiceEndpoint()),
              ex);
        }
      }

      boolean verifyCertificate =
          config.getVerifyCertificate() == null || config.getVerifyCertificate();

      KinesisIO.Read readTransform =
          KinesisIO.read()
              .withStreamName(config.getStreamName())
              .withClientConfiguration(
                  ClientConfiguration.builder()
                      .credentialsProvider(provider)
                      .region(Region.of(config.getRegion()))
                      .endpoint(endpoint)
                      .skipCertificateVerification(!verifyCertificate)
                      .build());

View on GitHub (pinned to 12126d8942)