infiniflow/ragflow · error · ValueError

[DocGenerator] Font size must be greater than or equal to 12

Error message

[DocGenerator] Font size must be greater than or equal to 12

What it means

Raised by DocGeneratorParam.check (agent/component/docs_generator.py) after check_positive_number passes: font_size is numeric and positive but below the enforced minimum of 12. The floor exists because generated documents render an overlay/footer and smaller sizes produce unreadable or mis-rendered output with the bundled PDF/DOCX pipeline.

Source

Thrown at agent/component/docs_generator.py:72

        self.font_size = 12
        self.outputs = {
            "doc_id": {"value": "", "type": "string"},
            "filename": {"value": "", "type": "string"},
            "mime_type": {"value": "", "type": "string"},
            "size": {"value": 0, "type": "number"},
            "download": {"value": "", "type": "string"},
        }

    def check(self):
        self.check_empty(self.content, "[DocGenerator] Content")
        self.check_valid_value(
            self.output_format,
            "[DocGenerator] Output format",
            ["pdf", "docx", "txt", "markdown", "html"],
        )
        self.check_positive_number(self.font_size, "[DocGenerator] Font size")
        if self.font_size < 12:
            raise ValueError("[DocGenerator] Font size must be greater than or equal to 12")


class DocGenerator(Message, ABC):
    component_name = "DocGenerator"
    _default_output_directory = os.path.join(tempfile.gettempdir(), "doc_outputs")
    _overlay_margin = 36
    _overlay_font_size = 9
    _pdf_main_font = "Noto Sans CJK SC"
    _pdf_cjk_font = "Noto Sans CJK SC"
    _pdf_overlay_font = "STSong-Light"

    def get_input_form(self) -> dict[str, dict]:
        return {
            "content": {
                "name": "Content",
                "type": "text",
            }
        }

View on GitHub (pinned to 554fb1133a)

Solutions

  1. Set font_size to 12 or higher (e.g. 12, 14) in the DocGenerator component settings
  2. If smaller text is truly needed, adjust the document content/template instead of the generator font size
  3. Programmatically clamp: font_size = max(12, font_size)

Example fix

# before
"font_size": 10

# after
"font_size": 12
Defensive patterns

Strategy: validation

Validate before calling

font_size = config.get('font_size', 12)
if not isinstance(font_size, (int, float)) or font_size < 12:
    font_size = 12  # enforce generator minimum
param.font_size = font_size

Type guard

def is_valid_font_size(v) -> bool:
    return isinstance(v, (int, float)) and not isinstance(v, bool) and v >= 12

Try / catch

try:
    param.check()
except ValueError as e:
    if 'Font size' in str(e):
        param.font_size = 12
    else:
        raise

Prevention

When it happens

Trigger: Setting the DocGenerator component's font_size to any positive value less than 12 (e.g. 9, 10.5, 11) in the canvas configuration. Fires during parameter validation when the component is saved or the agent runs.

Common situations: Users wanting compact documents setting 10 or 11; defaults from templates built for other generators; copying a font size from a CSS/web context where 10-14px is normal.

Related errors


AI-assisted analysis of infiniflow/ragflow@554fb1133a (2026-08-15). Data as JSON: /api/errors/a668c19e7c845f64. Report an issue: GitHub.