hiyouga/LlamaFactory · error · ValueError

No JSON/JSONL files found in the specified path: {cloud_path

Error message

No JSON/JSONL files found in the specified path: {cloud_path}.

What it means

The cloud JSON loader lists the path (if it is a directory) or uses it directly, filters entries to .json/.jsonl suffixes, and raises ValueError when nothing survives the filter. Data files with other extensions (e.g. .json.gz, .parquet, .txt) or a directory containing only those are rejected.

Source

Thrown at src/llamafactory/data/data_utils.py:201

def read_cloud_json(cloud_path: str) -> list[Any]:
    r"""Read a JSON/JSONL file from cloud storage (S3 or GCS).

    Args:
        cloud_path: str
            Cloud path in the format:
            - 's3://bucket-name/file.json' for AWS S3
            - 'gs://bucket-name/file.jsonl' or 'gcs://bucket-name/file.jsonl' for Google Cloud Storage
    """
    try:
        fs = setup_fs(cloud_path, anon=True)  # try with anonymous access first
    except Exception:
        fs = setup_fs(cloud_path)  # try again with credentials

    # filter out non-JSON files
    files = [x["Key"] for x in fs.listdir(cloud_path)] if fs.isdir(cloud_path) else [cloud_path]
    files = list(filter(lambda file: file.endswith(".json") or file.endswith(".jsonl"), files))
    if not files:
        raise ValueError(f"No JSON/JSONL files found in the specified path: {cloud_path}.")

    return sum([_read_json_with_fs(fs, file) for file in files], [])

View on GitHub (pinned to f28afaf635)

Solutions

  1. Ensure the target contains files ending exactly in .json or .jsonl (lowercase).
  2. Point the path directly at the file: s3://bucket/data/train/data.jsonl instead of a parent directory.
  3. Convert parquet/other formats to json/jsonl before uploading, or load them locally via dataset_info's常规 columns.
  4. Flatten nested directories so the JSON files sit at the listed prefix.

Example fix

# before
{"file_name": "s3://my-bucket/data"}  # dir holds parquet files

# after
# convert to jsonl, upload, then
{"file_name": "s3://my-bucket/data/train.jsonl"}
Defensive patterns

Strategy: validation

Validate before calling

fs = fsspec.filesystem("s3")
files = [x["Key"] for x in fs.listdir(cloud_path)] if fs.isdir(cloud_path) else [cloud_path]
json_files = [f for f in files if f.endswith((".json", ".jsonl"))]
assert json_files, "no .json/.jsonl files at path — convert or point directly at a file"

Prevention

When it happens

Trigger: Passing a cloud directory containing parquet/csv/arrow files; file named data.JSON (uppercase) or data.json.gz; pointing at a prefix whose JSON files live one level deeper (listing is not recursive by default in this helper).

Common situations: Converting a HF dataset hosted as parquet on S3/GCS and assuming the cloud loader handles it; nested folder layouts like s3://bucket/data/train/*.json where the prefix given is s3://bucket/data.

Related errors


AI-assisted analysis of hiyouga/LlamaFactory@f28afaf635 (2026-08-14). Data as JSON: /api/errors/ea1fe0a86ec93083. Report an issue: GitHub.