Missing 'name' attribute in 'GCSFile' object when accessing PDF files
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 398
- Forks
- 181
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 36
Description
Description:
In the context of using gcsfs with llama-index for reading files from a GCP bucket, an error occurs for PDF files indicating that the 'GCSFile' object has no attribute 'name'. This issue does not occur when accessing DOCX files. It suggests that there may be an inconsistency or a bug in how gcsfs handles file metadata, specifically for PDF files.
import google.auth
from llama_index.core import SimpleDirectoryReader
from gcsfs import GCSFileSystem
from fs_gcsfs import GCSFS
def __load_gcp_bucket(bucket_path: str):
credentials, project_id = google.auth.default(
scopes=["https://www.googleapis.com/auth/devstorage.read_only"]
)
gcp_fs = GCSFileSystem(project=project_id, token=credentials)
reader = SimpleDirectoryReader(
input_dir=bucket_path,
fs=gcp_fs,
)
documents = reader.load_data()
return documents
documents = __load_gcp_bucket("<bucket-path>/")
print(documents)
Version:
gcsfs: (specify the version you're using, e.g.,2023.6.0)
Steps to Reproduce:
- Use
GCSFileSystemfromgcsfsto access files in a GCP bucket. - Attempt to read metadata from both
.pdfand.docxfiles. - Compare the behavior and output to identify the absence of the
nameattribute in the case of PDF files.
Relevant Logs/Tracebacks:
Failed to load file <GCS bucket path>/file.pdf with error: 'GCSFile' object has no attribute 'name'. Skipping...
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the error with GCSFileSystem against both PDF and DOCX objects, then inspect how GCSFile exposes metadata when used by SimpleDirectoryReader. Compare the two paths and confirm that the relevant file identity is available consistently for PDF loading, with a regression check covering the reported traceback.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- google-cloud, python
- Domain
- cloud
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100