fix: Resolve ENAMETOOLONG errors with Korean chat titles and implement filename safety#480
Open
bongho wants to merge 1 commit intoglowingjade:mainfrom
Open
fix: Resolve ENAMETOOLONG errors with Korean chat titles and implement filename safety#480bongho wants to merge 1 commit intoglowingjade:mainfrom
bongho wants to merge 1 commit intoglowingjade:mainfrom
Conversation
…t filename safety ## 주요 변경사항 (Key Changes) ### ChatManager.ts - **파일명 길이 제한**: MAX_FILENAME_LENGTH (200자) 및 MAX_CHAT_TITLE_LENGTH (100자) 상수 추가 - **안전한 파일명 생성**: createSafeEncodedTitle() 함수로 긴 제목을 해시값과 함께 축약 처리 - **에러 복구 메커니즘**: ENAMETOOLONG 에러 발생 시 자동으로 짧은 제목으로 재시도하는 create/update 메소드 오버라이드 - **제목 검증**: validateAndSanitizeChatTitle() 함수로 빈 제목 검증 및 길이 제한 적용 - **파일명 파싱 개선**: 축약된 제목의 경우 'Loading...' 플레이스홀더 사용 후 실제 파일에서 제목 읽기 - **마이그레이션 유틸리티**: migrateExistingLongFilenames() 메소드로 기존 긴 파일명 변환 ### ChatManager.test.ts - **종합적인 테스트 추가**: 파일명 길이 안전성, 한글 문자 처리, 제목 검증 테스트 - **path-browserify 모킹**: 테스트 환경에서 경로 처리 개선 - **기존 roundtrip 테스트 업데이트**: 긴 제목 처리 로직 반영 ## 해결된 문제 - ENAMETOOLONG 파일 시스템 에러 (특히 한글 제목) - 매우 긴 채팅 제목으로 인한 파일 생성 실패 - 기존 긴 파일명 파일들의 호환성 문제 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
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 ENAMETOOLONG file system errors caused by Korean chat titles and very long titles. The issue occurred when Korean characters were URL-encoded, creating extremely long filenames that exceeded filesystem limits.
Key Changes
🔧 ChatManager.ts
createSafeEncodedTitle()function with hash-based truncation for uniquenesscreate/updatemethods to automatically retry with shortened titles on ENAMETOOLONG errorsvalidateAndSanitizeChatTitle()function for empty title validation and length enforcementmigrateExistingLongFilenames()method to convert existing problematic filenames🧪 ChatManager.test.ts
Problem Solved
Before: Korean title → URL encoding expansion → extremely long filename → ENAMETOOLONG error
After: Safe length limits + hash-based uniqueness
Test Results
Migration Support
For existing installations with long filenames, the
migrateExistingLongFilenames()method can safely convert problematic files to the new format while preserving all data.Backward Compatibility
The changes are fully backward compatible. Existing shorter filenames continue to work unchanged, and the parsing logic gracefully handles both old and new filename formats.