Skip to content

Bare except on os.mkdir in load_sample_documents #869

Description

@cybermaggedon

Description

In trustgraph-cli/trustgraph/cli/load_sample_documents.py (lines 31–34):

try:
    os.mkdir("doc-cache")
except:
    pass

Problem

The intent is to ignore "directory already exists", but bare except: also silently swallows permission errors, read-only filesystem errors, and any other OS-level failure. The user gets no feedback when the cache directory can't be created, and the script fails later with a confusing error when it tries to write into the missing directory.

Suggested fix

Please PR against the latest release/vX.Y branch.

os.makedirs("doc-cache", exist_ok=True)

This is a one-line fix. os.makedirs with exist_ok=True handles the "already exists" case and lets real errors (permissions, disk full) propagate naturally.

What you'll learn

How the CLI sample-document loader works, and the difference between os.mkdir and os.makedirs.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions