Fix ETag format to prevent WsgiDAV crashes on PUT requests#55
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR fixes a regression where WsgiDAV would crash with a 500 error when handling PUT requests to WebDAV resources (note.json and page_1.ink files) due to improperly formatted ETags. The issue occurred because ETags were being returned as quoted ISO timestamps, which violated WsgiDAV's
checked_etagvalidator.Key Changes
Replaced ISO timestamp-based ETags with hash-based ETags: Changed
_safe_etag()to generate SHA256 hex digests from resource identity components (resource type, ID, page number, and last-modified timestamp) instead of returning raw ISO timestamps. Hex digests are guaranteed to be quote-free and satisfy WsgiDAV's validation rules.Updated ETag generation for NoteMetaFile: Modified
get_etag()to include the note ID and type identifier in the hash, ensuring the ETag changes only when the note's content actually changes.Updated ETag generation for InkFile: Modified
get_etag()to include the page's note ID, page number, and type identifier in the hash for proper cache invalidation.Added comprehensive test coverage:
checked_etagvalidatorImplementation Details
_safe_etag()function now accepts variable arguments representing resource identity componentshttps://claude.ai/code/session_01UCTNs51gDsbdzVXExMUDAg