zylon-ai/private-gpt · error · ValueError

Folder {folder_path} is not allowed for ingestion

Error message

Folder {folder_path} is not allowed for ingestion

What it means

Raised by LocalIngestWorker._validate_folder when the requested folder is not inside any entry of data.local_ingestion.allow_ingest_from and no '*' wildcard is present. This allowlist constrains the local ingestion script to pre-approved directory trees; a '*' entry disables the restriction entirely. Note the code validates each discovered file path with Path.is_relative_to, so the allowlist entries must be parents of the files being ingested.

Source

Thrown at scripts/ingest_folder.py:43

        self._files_under_root_folder: list[Path] = []

        self.is_local_ingestion_enabled = setting.data.local_ingestion.enabled
        self.allowed_local_folders = setting.data.local_ingestion.allow_ingest_from

    def _validate_folder(self, folder_path: Path) -> None:
        if not self.is_local_ingestion_enabled:
            raise ValueError(
                "Local ingestion is disabled."
                "You can enable it in settings `ingestion.enabled`"
            )

        # Allow all folders if wildcard is present
        if "*" in self.allowed_local_folders:
            return

        for allowed_folder in self.allowed_local_folders:
            if not folder_path.is_relative_to(allowed_folder):
                raise ValueError(f"Folder {folder_path} is not allowed for ingestion")

    def _find_all_files_in_folder(self, root_path: Path, ignored: list[str]) -> None:
        """Search all files under the root folder recursively.

        Count them at the same time
        """
        for file_path in root_path.iterdir():
            if file_path.is_file() and file_path.name not in ignored:
                self.total_documents += 1
                self._validate_folder(file_path)
                self._files_under_root_folder.append(file_path)
            elif file_path.is_dir() and file_path.name not in ignored:
                self._find_all_files_in_folder(file_path, ignored)

    def ingest_folder(self, folder_path: Path, ignored: list[str]) -> None:
        # Count total documents before ingestion
        self._find_all_files_in_folder(folder_path, ignored)
        self._ingest_all(self._files_under_root_folder)

View on GitHub (pinned to 4a030776a3)

Solutions

  1. Add the exact absolute path of the corpus root to data.local_ingestion.allow_ingest_from
  2. Ensure both the allowlist entries and the CLI --folder argument are absolute, consistently resolved paths (no mixing of relative/absolute)
  3. If you trust all paths, add '*' to allow_ingest_from to bypass the check
  4. For containers, align the mounted path with the allowlisted path (mount the corpus at the path listed in settings)

Example fix

# settings.yaml - before
data:
  local_ingestion:
    enabled: true
    allow_ingest_from: [/data/docs]

# CLI ingests /srv/corpus -> rejected

# after
data:
  local_ingestion:
    enabled: true
    allow_ingest_from: [/data/docs, /srv/corpus]
Defensive patterns

Strategy: validation

Validate before calling

from pathlib import Path

def folder_allowed(folder: Path, allowlist: list[Path]) -> bool:
    if "*" in allowlist:
        return True
    folder = folder.resolve()
    return any(folder.is_relative_to(Path(a).resolve()) for a in allowlist)

# call before starting ingestion

Type guard

null

Try / catch

try:
    worker.ingest_folder(root, ignored)
except ValueError as e:
    if "not allowed for ingestion" in str(e):
        raise SystemExit(f"add {root.resolve()} to data.local_ingestion.allow_ingest_from")
    raise

Prevention

When it happens

Trigger: allow_ingest_from: [/data/docs] but ingesting /home/user/docs; relative vs absolute path mismatch (entry stored as 'data/docs' while folder_path is resolved absolute); allowlist missing entirely (empty list) so every folder is rejected; trailing-slash or symlinked-path mismatches that break is_relative_to.

Common situations: Moving the corpus to a new mount point without updating settings; running the script inside a container where the host path differs from the container path; symlinked data directories whose resolved path escapes the allowlisted prefix; operators enabling ingestion (error 434) but forgetting the second required setting.

Related errors


AI-assisted analysis of zylon-ai/private-gpt@4a030776a3 (2026-08-15). Data as JSON: /api/errors/ce3f197f3de911b8. Report an issue: GitHub.