apache/beam · error · InvalidLocationException

DataStoreV1 location must be in the following format…

Error message

DataStoreV1 location must be in the following format: 'projectId/kind' but was:{location}

What it means

DataStoreV1SchemaIOProvider.validateLocation checks the provided location against a regex Matcher expecting the format 'projectId/kind'. If the location is non-null but doesn't match (wrong number of segments, illegal characters, extra slashes), it throws InvalidLocationException "DataStoreV1 location must be in the following format: 'projectId/kind' but was:<location>".

Solutions

  1. Format the location as exactly 'projectId/kind', e.g. my-project/MyKind.
  2. Remove any namespace, leading scheme, or extra path segments from the location.
  3. If you need a namespace, it is not supported by this location format — set the namespace via a different option or restructure the kind.

Example fix

// before
--location=https://datastore.googleapis.com/project/my-project/kind/MyKind
// after
--location=my-project/MyKind
Defensive patterns

Strategy: validation

Validate before calling

java.util.regex.Pattern LOCATION = java.util.regex.Pattern.compile("^[^/]+/[^/]+$");
if (location == null || !LOCATION.matcher(location).matches()) {
  throw new IllegalArgumentException("Location must be 'projectId/kind', got: " + location);
}

Type guard

static boolean isValidDataStoreV1Location(String location) {
  return location != null && location.matches("^[^/]+/[^/]+$");
}

Try / catch

try {
  SchemaIO io = new DataStoreV1SchemaIOProvider().fromValue(location);
} catch (InvalidLocationException e) {
  // surface e.getMessage() (includes the bad location) and stop job creation
}

Prevention

When it happens

Trigger: Passing a location like 'my-project' (no kind), 'project/kind/extra', a full URL, or a name with unsupported characters to the DataStoreV1 SchemaIO.

Common situations: Users pasting a full Datastore resource path or URL instead of projectId/kind; namespace included in the location (not supported — see TODO in the code); typos such as spaces or Windows path separators.

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/e4f17a9549647ab7. Report an issue: GitHub.

Appendix: source

Thrown at sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/datastore/DataStoreV1SchemaIOProvider.java:175

    private String determineKeyField(String configKey) {
      if (configKey != null && configKey.isEmpty()) {
        throw new InvalidConfigurationException(
            String.format("'%s' property cannot be null.", KEY_FIELD_PROPERTY));
      } else if (configKey != null) {
        return configKey;
      } else {
        return DEFAULT_KEY_FIELD;
      }
    }

    private void validateLocation(String location, Matcher matcher) {
      // TODO: allow users to specify a namespace in a location string.
      if (location == null) {
        throw new InvalidLocationException("DataStoreV1 location must be set. ");
      }
      if (!matcher.matches()) {
        throw new InvalidLocationException(
            "DataStoreV1 location must be in the following format: 'projectId/kind'"
                + " but was:"
                + location);
      }
    }
  }
}

View on GitHub (pinned to 12126d8942)