Skip to content

Prevent os.makedirs("") crash for relative session file paths #189

Description

@ajma

high

If the environment variable MANAGED_SPARK_CONNECT_ACTIVE_SESSION_FILE_PATH (or its deprecated alias) is configured as a relative path without any directory components (e.g., "session.json"), os.path.dirname(file_path) will return an empty string "". Calling os.makedirs("", exist_ok=True) will then raise a FileNotFoundError, crashing the session creation process.

To prevent this, ensure that os.makedirs is only called when the directory path is non-empty.

                            dir_name = os.path.dirname(file_path)
                            if dir_name:
                                os.makedirs(dir_name, exist_ok=True)

Originally posted by @gemini-code-assist[bot] in #188 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions