VectifyAI/PageIndex · error · ValueError

Unsupported PDF parser: {pdf_parser}

Error message

Unsupported PDF parser: {pdf_parser}

What it means

get_page_tokens supports only specific PDF parser backends (e.g. pymupdf vs others selected by the pdf_parser option). Passing any other string raises ValueError because there is no code path to extract per-page text for that parser name.

Source

Thrown at pageindex/utils.py:540

            page_text = page.extract_text()
            token_length = litellm.token_counter(model=model, text=page_text)
            page_list.append((page_text, token_length))
        return page_list
    elif pdf_parser == "PyMuPDF":
        import pymupdf
        if isinstance(pdf_path, BytesIO):
            pdf_stream = pdf_path
            doc = pymupdf.open(stream=pdf_stream, filetype="pdf")
        elif isinstance(pdf_path, str) and os.path.isfile(pdf_path) and pdf_path.lower().endswith(".pdf"):
            doc = pymupdf.open(pdf_path)
        page_list = []
        for page in doc:
            page_text = page.get_text()
            token_length = litellm.token_counter(model=model, text=page_text)
            page_list.append((page_text, token_length))
        return page_list
    else:
        raise ValueError(f"Unsupported PDF parser: {pdf_parser}")

        

def get_text_of_pdf_pages(pdf_pages, start_page, end_page):
    if start_page is None or end_page is None:
        return ""
    text = ""
    for page_num in range(start_page-1, end_page):
        text += pdf_pages[page_num][0]
    return text

def get_text_of_pdf_pages_with_labels(pdf_pages, start_page, end_page):
    if start_page is None or end_page is None:
        return ""
    text = ""
    for page_num in range(start_page-1, end_page):
        text += f"<physical_index_{page_num+1}>\n{pdf_pages[page_num][0]}\n<physical_index_{page_num+1}>\n"
    return text

View on GitHub (pinned to afb5e11976)

Solutions

  1. Check the function's if/elif branches just above the raise to see the accepted parser names (e.g. 'pymupdf')
  2. Set pdf_parser to a supported value or omit it to use the default
  3. Trim whitespace/casing mistakes in the config value

Example fix

# before
page_index_main(pdf, pdf_parser='pdfplumber')
# after
page_index_main(pdf, pdf_parser='pymupdf')
Defensive patterns

Strategy: validation

Validate before calling

SUPPORTED_PARSERS = {'pymupdf'}  # keep in sync with get_page_tokens
if cfg.get('pdf_parser') not in SUPPORTED_PARSERS | {None}:
    raise ValueError(f"bad pdf_parser: {cfg.get('pdf_parser')!r}")

Type guard

def is_supported_parser(p):
    return p is None or p in {'pymupdf'}

Try / catch

try:
    page_index_main(pdf, pdf_parser=parser)
except ValueError as e:
    if 'Unsupported PDF parser' in str(e):
        page_index_main(pdf)  # fall back to default parser
    else:
        raise

Prevention

When it happens

Trigger: Calling page_index_main (or configuring the pipeline) with pdf_parser set to an unsupported value, e.g. 'pdfplumber', 'pypdf', or a typo like 'pymupdf ' with trailing space.

Common situations: Copy-pasted config from another tool that uses a different parser name, typo in YAML config, or assuming a parser that a newer/older library version supports.

Related errors


AI-assisted analysis of VectifyAI/PageIndex@afb5e11976 (2026-08-27). Data as JSON: /api/errors/9c620f2fbc0f64a3. Report an issue: GitHub.