apache/beam · error · ValueError
f'Invalid path or url
Error message
f'Invalid path or url: {jar}' What it means
java_jar (yaml_provider.py:313), the 'javaJar' provider type constructor, accepts a jar that must be either an existing local file path or a URL with both scheme and netloc. If the jar path does not exist and does not parse as a full URL, it raises ValueError 'Invalid path or url'.
Solutions
- Give an absolute path to the jar or run the pipeline from the directory containing it.
- Use a full URL including scheme and host, e.g. https://host/path/lib.jar or file:///path/lib.jar.
- Verify existence first: os.path.exists(jar) in the launching environment; remember provider_base_path is joined later via _join_url_or_filepath.
Example fix
# before
- type: javaJar
config:
jar: example.com/lib.jar
# after
- type: javaJar
config:
jar: https://example.com/lib.jar Defensive patterns
Strategy: validation
Validate before calling
import os, urllib.parse
def validate_jar(jar):
if os.path.exists(jar):
return
p = urllib.parse.urlparse(jar)
if not p.scheme or not p.netloc:
raise SystemExit(f'jar must be an existing file or full URL: {jar}') Try / catch
try:
provider = ExternalProvider.provider_from_spec(src, spec)
except ValueError as e:
log.error('javaJar config problem: %s', e)
raise Prevention
- Use absolute paths for local jars or full URLs with scheme and host.
- Run pipelines from a known working directory or resolve jar paths at spec-generation time.
- Verify jar reachability (os.path.exists / HTTP HEAD) before launching.
When it happens
Trigger: Passing jar: 'my-lib.jar' when the file doesn't exist relative to the working directory; passing a bare hostname or scheme-less path like 'example.com/lib.jar'; typos in a local absolute path.
Common situations: Running the pipeline from a different cwd than where the jar lives; forgetting file:// or https:// on a remote jar; backslashes or spaces in Windows paths.
Understand the failure class
Background: "Invalid URL" / "URL cannot be empty": fix the malformed or missing URL behind request-construction failures — this error's family across 50 libraries.
Related errors
- At most one of --create_test and --fix_tests may be…
- Cannot convert element of type
- Cannot create a temporary directory for root path prefix
- "Cannot specify 'callable' with 'path' and 'name' for…
- Chain at missing transforms property.
AI-assisted analysis of apache/beam@12126d8942 (2026-09-13).
Data as JSON: /api/errors/e55dbd110d7e1a51.
Report an issue: GitHub.
Appendix: source
Thrown at sdks/python/apache_beam/yaml/yaml_provider.py:313
raise NotImplementedError(
f'Unknown provider type: {type} '
f'at line {SafeLineLoader.get_line(spec)}.')
@classmethod
def register_provider_type(cls, type_name):
def apply(constructor):
cls._provider_types[type_name] = constructor
return constructor
return apply
@ExternalProvider.register_provider_type('javaJar')
def java_jar(urns, provider_base_path, jar: str):
if not os.path.exists(jar):
parsed = urllib.parse.urlparse(jar)
if not parsed.scheme or not parsed.netloc:
raise ValueError(f'Invalid path or url: {jar}')
return ExternalJavaProvider(
urns, lambda: _join_url_or_filepath(provider_base_path, jar))
@ExternalProvider.register_provider_type('mavenJar')
def maven_jar(
urns,
*,
artifact_id,
group_id,
version,
repository=subprocess_server.JavaJarServer.MAVEN_CENTRAL_REPOSITORY,
classifier=None,
appendix=None):
return ExternalJavaProvider(
urns, lambda: subprocess_server.JavaJarServer.path_to_maven_jar(
artifact_id=artifact_id, group_id=group_id, version=version,
repository=repository, classifier=classifier, appendix=appendix))View on GitHub (pinned to 12126d8942)