google / google/glazier

MkDir creates the parent of the requested directory, and nothing at all for the documented example

Open Beginner friendly
#798 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
1.3k
Forks
96
Avg merge
3d 15h
Merged PRs (30d)
4

Description

`MkDir` creates the parent of the directory it is asked for, not the directory itself. For the example in the docs it creates nothing at all and reports success.

`docs/actions.md` documents the argument as a directory:

```
* Arg1[str]: Full path name of directory

MkDir: ['C:\Glazier_Cache']
```

`MkDir.Run()` passes that straight to `file_util.CreateDirectories()` (`file_system.py:127`), whose own docstring describes a different kind of argument:

```python
"""Create directory if the path to a file doesn't exist.

Args:
path: The full file path to where a file will be placed.
"""
dirname = os.path.dirname(path)
if not os.path.isdir(dirname):
os.makedirs(dirname)
```

So the last component is stripped. Measured on CPython 3.13.13:

```python
file_util.CreateDirectories(r'...\Glazier_Cache')
# target exists after call? False
# parent exists after call? True
```

For the documented example the effect is silence rather than a wrong directory, because `os.path.dirname(r'C:\Glazier_Cache')` is `'C:\'`, which already exists, so the `isdir` guard short-circuits and nothing is created. No exception is raised, so the build step reports success.

This is not platform-specific. `os.path.dirname('/Glazier_Cache')` is `'/'` on POSIX and behaves the same way.

The two docstrings are each self-consistent, so the defect is the pairing: `CreateDirectories` is a "make room for this file" helper and `MkDir` is documented as "make this directory". Either `MkDir` should pass `os.path.join(path, '')`, or it needs its own call to `os.makedirs`.

I have no Linux or macOS machine, so the POSIX sentence above is read from `posixpath` semantics rather than measured.

Contributor guide

Open the contributing guide

Research direction

Read docs/actions.md and trace MkDir.Run() to file_system.py:127, then reproduce the documented path behavior on the supported platforms. Verify that the requested directory exists after the action, that existing-directory handling still succeeds, and that the relevant MkDir or file utility tests pass.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
tooling
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
85/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.