-
Notifications
You must be signed in to change notification settings - Fork 18
Fix OSError on Windows by sanitizing process recording filenames #379
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
This commit addresses and resolves several `too-many-positional-arguments` and `unused-argument` linting errors reported by pylint. The changes primarily involve adding `too-many-positional-arguments` to existing `pylint: disable` directives where the function signatures are fixed by external frameworks (Django, SQLAlchemy) or by internal design requirements (e.g., `__new__` methods, `HttpServerRequestEvent` init). Additionally, an `unused-argument` was fixed by renaming a parameter with a leading underscore to indicate its intentional non-use. These modifications ensure that the codebase adheres to the pylint standards without altering the intended functionality or API compatibility.
Replace colons in ISO 8601 timestamps with hyphens when generating filenames for process recordings. This prevents OSErrors on Windows systems where colons are invalid characters in filenames. Includes a regression test to verify that generated filenames do not contain colons. Fixes #377
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR fixes a Windows compatibility issue where process recordings fail with an OSError because the ISO 8601 timestamp format includes colons, which are invalid in Windows filenames. The fix replaces colons in the timestamp with hyphens.
Changes:
- Modified
_appmap/recording.pyto sanitize the timestamp by replacing colons with hyphens - Added a regression test to verify generated filenames don't contain colons
- Updated pylint disable comments across multiple files to include
too-many-positional-argumentsfor compatibility with newer pylint versions
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| _appmap/recording.py | Modified process recording filename generation to replace colons with hyphens in timestamps, fixing Windows compatibility |
| _appmap/test/test_recording.py | Added regression test test_process_recording_filename_is_sanitized to ensure filenames don't contain colons |
| appmap/sqlalchemy.py | Added too-many-positional-arguments to pylint disables for callback functions |
| appmap/pytest.py | Changed unused parameter name from item to _item to follow Python conventions |
| appmap/django.py | Added too-many-positional-arguments to pylint disable for database wrapper callback |
| _appmap/web_framework.py | Added too-many-positional-arguments to pylint disables for web framework functions |
| _appmap/test/test_django.py | Added too-many-positional-arguments to pylint disable for test client adaptor |
| _appmap/test/test_configuration.py | Added too-many-positional-arguments to pylint disable for test class |
| _appmap/importer.py | Added too-many-positional-arguments to pylint disable for FilterableFn.__new__ |
| _appmap/event.py | Added too-many-positional-arguments to pylint disable for HttpServerRequestEvent.__init__ |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| iso_time = now.isoformat(timespec="seconds").replace("+00:00", "Z") | ||
| process_id = os.getpid() | ||
| appmap_name = f"{iso_time}_{process_id}" | ||
| appmap_name = f"{iso_time}-{process_id}".replace(":","-") |
Copilot
AI
Jan 26, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line makes two changes that should be documented separately:
- Replaces colons in the timestamp with hyphens (to fix Windows compatibility)
- Changes the separator between timestamp and process_id from underscore to hyphen
The PR description only mentions the first change. While both changes work correctly, the separator change appears to be unintentional or at least undocumented.
Additionally, the suggested fix in issue #377 was to remove colons entirely using .replace(':', ''), but this implementation replaces them with hyphens instead. Both approaches are valid for Windows compatibility, but this deviation from the suggested fix should be acknowledged.
Consider either:
- Reverting the separator to underscore:
f"{iso_time.replace(':', '-')}_{process_id}" - Or documenting why the hyphen separator is preferred over underscore
Context
Process recordings generate a default filename incorporating a timestamp (e.g., 2023-10-27T10:00:00Z).
Problem
The ISO 8601 timestamp format includes colons (
:), which are reserved characters on Windows file systems. This caused anOSErrorwhen attempting to save process recordings on Windows machines (issue #377).Solution
This PR updates the filename generation logic in
_appmap/recording.pyto replace colons with hyphens in the timestamp string (e.g.,2023-10-27T10-00-00Z).Changes
_appmap/recording.py: Added.replace(":", "-")to theappmap_namegeneration._appmap/test/test_recording.py: Added a regression testtest_process_recording_filename_is_sanitizedto ensure generated filenames are valid and free of colons.Validation