get_tables() method writes files to incorrect locations #506

Open
opened 2026-02-16 00:18:04 -05:00 by yindo · 1 comment
Owner

Originally created by @leosmfk on GitHub (Jul 17, 2025).

Summary

The get_tables() method in llama_cloud_services has a bug that causes CSV files to be written to incorrect locations, including the current working directory and root filesystem, instead of the specified download_path.

Environment

  • Package: llama_cloud_services (latest version)
  • Python: 3.13.4
  • OS: macOS

Bug Description

When extracting tables from documents using get_tables(), the method:

  1. Creates some files in the correct target directory
  2. Creates other files in the current working directory (with names like t0.csv, t1.csv, etc.)
  3. May attempt to write to root filesystem (/1.csv, /2.csv) causing permission errors

Reproduction Steps

Test Case 1: Relative Path (Partially Works)

from llama_cloud_services import LlamaParse

parser = LlamaParse(api_key="your_key", result_type="markdown")
json_result = parser.get_json_result("sample-tables.pdf")

# This creates files in BOTH correct and incorrect locations
result = parser.get_tables(json_result, "tables/")

Result:

  • Some files created in "tables/" directory
  • 🚨 Other files created as "t0.csv", "t1.csv" in current directory

Test Case 2: Absolute Path (Completely Fails)

import tempfile

temp_dir = tempfile.mkdtemp()  # e.g., /var/folders/xyz/temp_abc
result = parser.get_tables(json_result, temp_dir)

Result:

  • Error: [Errno 30] Read-only file system: '/1.csv'
  • Files attempted to be written to root filesystem

Root Cause Analysis

The bug appears to be in the duplicate filename handling logic within the extract_tables_from_json_results() function. When processing multiple tables, the path manipulation becomes corrupted, causing files to be written to incorrect locations.

Test Results

I tested with a document containing 25 tables:

Relative path test:

  • Expected: 25 files in "tables/" directory
  • Actual: 7 files in correct location + 7 files in current directory + 11 failures

Absolute path test:

  • Expected: 25 files in temp directory
  • Actual: Complete failure with root filesystem write attempts
Originally created by @leosmfk on GitHub (Jul 17, 2025). ## Summary The get_tables() method in llama_cloud_services has a bug that causes CSV files to be written to incorrect locations, including the current working directory and root filesystem, instead of the specified download_path. ## Environment - Package: llama_cloud_services (latest version) - Python: 3.13.4 - OS: macOS ## Bug Description When extracting tables from documents using get_tables(), the method: 1. Creates some files in the correct target directory 2. Creates other files in the current working directory (with names like t0.csv, t1.csv, etc.) 3. May attempt to write to root filesystem (/1.csv, /2.csv) causing permission errors ## Reproduction Steps ### Test Case 1: Relative Path (Partially Works) ```python from llama_cloud_services import LlamaParse parser = LlamaParse(api_key="your_key", result_type="markdown") json_result = parser.get_json_result("sample-tables.pdf") # This creates files in BOTH correct and incorrect locations result = parser.get_tables(json_result, "tables/") ``` **Result:** - ✅ Some files created in "tables/" directory - 🚨 Other files created as "t0.csv", "t1.csv" in current directory ### Test Case 2: Absolute Path (Completely Fails) ```python import tempfile temp_dir = tempfile.mkdtemp() # e.g., /var/folders/xyz/temp_abc result = parser.get_tables(json_result, temp_dir) ``` **Result:** - ❌ Error: [Errno 30] Read-only file system: '/1.csv' - Files attempted to be written to root filesystem ## Root Cause Analysis The bug appears to be in the duplicate filename handling logic within the extract_tables_from_json_results() function. When processing multiple tables, the path manipulation becomes corrupted, causing files to be written to incorrect locations. ## Test Results I tested with a document containing 25 tables: **Relative path test:** - Expected: 25 files in "tables/" directory - Actual: 7 files in correct location + 7 files in current directory + 11 failures **Absolute path test:** - Expected: 25 files in temp directory - Actual: Complete failure with root filesystem write attempts
yindo added the bug label 2026-02-16 00:18:04 -05:00
Author
Owner

@Athossss commented on GitHub (Jul 29, 2025):

Another user affected by the same problem. Please fix!

@Athossss commented on GitHub (Jul 29, 2025): Another user affected by the same problem. Please fix!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: run-llama/llama_cloud_services#506