Skip to content

PRS005 - File Size Exceeded

Description

The file path provided for validation exceeds the maximum allowed file size. This check occurs before reading the file to prevent memory exhaustion attacks.

Severity

Error

When This Occurs

  • A file path is passed to validate() and the file size exceeds max_input_size
  • Default limit is 10 MB (10,485,760 bytes)
  • This is checked before the file is read into memory

Example

from pathlib import Path
from dppvalidator import ValidationEngine

engine = ValidationEngine()
result = engine.validate(Path("huge_passport.json"))
# PRS005 if file size > 10 MB

Resolution

  1. Increase the size limit if needed:
from pathlib import Path
from dppvalidator import ValidationEngine

engine = ValidationEngine(max_input_size=50_000_000)  # 50 MB
result = engine.validate(Path("large_passport.json"))
  1. Read and filter the file manually:
import json
from dppvalidator import ValidationEngine

with open("large_passport.json") as f:
    data = json.load(f)

# Remove large embedded data
if "productImage" in data.get("credentialSubject", {}).get("product", {}):
    del data["credentialSubject"]["product"]["productImage"]

engine = ValidationEngine()
result = engine.validate(data)  # Pass dict directly
  1. Split into smaller documents if possible.

Difference from PRS004

  • PRS004: Triggered when in-memory data (string/dict) exceeds size limit
  • PRS005: Triggered when file size check fails before reading