Skip to content

Limit generated filename prefixes#456

Open
Sean-Kenneth-Doherty wants to merge 1 commit into
plotly:masterfrom
Sean-Kenneth-Doherty:fix-limit-generated-filenames
Open

Limit generated filename prefixes#456
Sean-Kenneth-Doherty wants to merge 1 commit into
plotly:masterfrom
Sean-Kenneth-Doherty:fix-limit-generated-filenames

Conversation

@Sean-Kenneth-Doherty
Copy link
Copy Markdown

Summary

Fixes #409 by applying the generated filename prefix length cap inside _next_filename() before it checks for existing files. This keeps direct helper use from probing the filesystem with overlong title-derived names, while preserving the existing determine_path() cap.

Changes

  • Add a shared generated-prefix limit constant.
  • Clamp prefixes inside _next_filename() before Path.exists() and Path.glob() calls.
  • Add regression coverage for direct _next_filename() calls with long prefixes and determine_path() with long figure titles.

Validation

  • uv run --directory src/py pytest tests/test_path_tools.py -q -> 20 passed
  • uv run --directory src/py ruff check kaleido/_utils/path_tools.py tests/test_path_tools.py -> passed
  • uv run --directory src/py ruff format --check kaleido/_utils/path_tools.py tests/test_path_tools.py -> passed
  • uv run --directory src/py python -m compileall -q kaleido/_utils/path_tools.py tests/test_path_tools.py -> passed
  • git diff --check -> passed

@Sean-Kenneth-Doherty
Copy link
Copy Markdown
Author

Fresh validation on the current branch head:\n\n- env TMPDIR=$PWD/.tmp-test uv run --directory src/py pytest tests/test_path_tools.py -q -> 20 passed\n- uv run --directory src/py ruff check kaleido/_utils/path_tools.py tests/test_path_tools.py -> passed\n- uv run --directory src/py ruff format --check kaleido/_utils/path_tools.py tests/test_path_tools.py -> passed\n- uv run --directory src/py python -m compileall -q kaleido/_utils/path_tools.py tests/test_path_tools.py -> passed\n- git diff --check origin/master...HEAD -> clean\n\nThe local worktree is clean after removing the temporary test directory.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

_next_filename() can cause unintended OSError for "File name too long" on Fedora/Red Hat

1 participant