Conversation
…tion, and test suite
…, and SDK operations
Owner
|
@tienoho jobs run failed |
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.
Overview
This PR addresses 14 distinct bugs and edge-case defects across the Flow Kit platform, spanning the FastAPI REST layer, Background Worker queue logic, Chrome MV3 Extension callback mechanism, FFmpeg media processing pipeline, cross-platform Windows compatibility (UTF-8 encoding and path normalization), and restores the complete YouTube integration module (
youtube/).All unit and integration tests pass at 100% (373 passed, 0 failed, 0 errors).
Key Fixes & Improvements
1. REST API & FastAPI Layer
Prevent Server Crash on Non-Integer HTTP Status Codes (
agent/api/flow.py):{"status": "failed", "error": "..."}, raisingHTTPException(result.get("status", 502), ...)triggeredTypeError: '<' not supported between instances of 'str' and 'int'inside Starlette's response handler._safe_status_code()helper to strictly sanitize and validate status codes into the HTTP error range (400 <= status <= 599), defaulting to502 Bad Gatewayfor non-integer or 2xx error responses across all 9 generation/upscale endpoints.Multi-Orientation Request Deduplication (
agent/api/requests.py):createandcreate_batchchecked existing active requests byscene_idandtypeonly, completely ignoringorientation. Submitting aHORIZONTALvideo generation while aVERTICALrequest was in progress caused the second request to be erroneously rejected as a duplicate (409 Conflictor silently skipped).and (not orient or r.get("orientation") == orient)to deduplication filters, allowing concurrent or subsequent generation for distinct orientations.Active Project State Corruption Fix on Windows (
agent/api/active_project.py):_read_state()openedactive_project.jsonusing system default encoding (cp1252on Windows). If a project title or description contained Unicode/Vietnamese characters,json.load()threwUnicodeDecodeError. The catch block treated this as a corrupted file and executed_clear_state(), wiping out the active project state.encoding="utf-8"inopen(_STATE_FILE)and addedensure_ascii=False/utf-8encoding to_write_state().2. Background Worker & Queue Logic
Fix Missing Character Reference Image URL (
agent/worker/processor.py):char.get("image_url"). In the SQLite schema, the column is namedreference_image_url, resulting inoutput_urlbeing set toNone.char.get("reference_image_url") or char.get("image_url").Character Generation Completion Check (
agent/worker/processor.py):_is_already_completedunconditionally returnedFalseforGENERATE_CHARACTER_IMAGE, violating Rule 8 by re-generating character reference images even when the entity already possessed a validmedia_id.bool(char and char.get("media_id"))forGENERATE_CHARACTER_IMAGEwhile preserving unconditional execution forREGENERATE_*andEDIT_*requests.3. Chrome MV3 Extension
X-Callback-SecretHeader (extension/background.js):sendToAgent(msg), HTTP POST callbacks to/api/ext/callbackdid not transmit theX-Callback-Secretreceived during the initial WebSocket handshake, leaving HTTP responses unauthenticated.headers['X-Callback-Secret'] = callbackSecretwhencallbackSecretis present.4. Media Services & Windows Cross-Platform Support
FFmpeg Concat Demuxer Path Escaping (
agent/services/post_process.py):.concat.txtwrote Windows backslashes (D:\path\clip.mp4), which FFmpeg concat demuxer interprets as escape sequences (causingNo such file or directoryor corrupt parsing).Path(p).as_posix()and addedencoding="utf-8"to file creation.FFmpeg Bundled Binary Fallback (
agent/services/post_process.py,agent/services/video_reviewer.py):ffmpegon PATH, subprocess calls failed withFileNotFoundError._ffmpeg_bin()helper with automatic fallback to the bundled executable provided byimageio_ffmpeg.Windows Symlink Privilege Fallback (
agent/services/video_reviewer.py):os.symlinkfailed withWinError 1314 (A required privilege is not held by the client)when unprivileged on Windows.shutil.copy2()when symlinking contact sheet frames fails.Cross-Platform Python Binary in TTS (
agent/services/tts.py):python3.10executable causedFileNotFoundErroron standard Windows installations.sys.executableonwin32.Standard File URI Format (
agent/sdk/services/operations.py):f"file://{_os.path.abspath(local)}"produced non-standard Windows URIs with backslashes (file://D:\...).Path(local).resolve().as_uri().5. Universal UTF-8 Normalization
encoding="utf-8"across all configuration, prompt, and JSON file I/O to eliminateUnicodeDecodeError/UnicodeEncodeErrorunder Windows default ANSI code page (cp1252):agent/config.py(models.json,providers.json,channel_rules.json)agent/api/projects.py(meta.json)agent/api/tts.py(templates_meta.json)agent/api/models.py(models.json)agent/api/providers.py(providers.json)agent/services/cli_providers.py(~/.codex/models_cache.json)agent/services/video_reviewer.py(Codex CLI output)tools/review_server.py(feedback.json)tests/unit/test_setup.py(fixtures with em-dashes—)tests/unit/test_cli_providers.py(cross-platform path assertions)6. Restored YouTube Integration Module
.gitignoreRefinement: Corrected.gitignoreline 9 fromyoutube(which blocked the entire module) toyoutube/channels/(safeguarding OAuth secrets, credentials, and tokens while tracking source code).youtube/auth.py: Created OAuth2 credential manager usingInstalledAppFlowand automatic token refresh viagoogle-auth-oauthlib.youtube/upload.py: Created full YouTube upload pipeline:detect_video_type(): Detects Shorts (<61s, vertical 9:16) vs Long-form.load_channel_rules(): Parses scheduling and quota constraints with default fallbacks.validate_upload(): Enforces daily quotas, min gap hours, and avoids posting during dead hours.auto_schedule(): Generates optimized release slots.upload_video(): Resumable chunked upload (10MB) via YouTube Data API v3 with SEO hashtags.tests/unit/test_youtube.py: Added comprehensive test suite covering rules parsing, validation, auto-scheduling, and video type detection.Verification & Test Results
Modified Files
.gitignoreagent/api/active_project.pyagent/api/flow.pyagent/api/models.pyagent/api/projects.pyagent/api/providers.pyagent/api/requests.pyagent/api/tts.pyagent/config.pyagent/sdk/services/operations.pyagent/services/cli_providers.pyagent/services/post_process.pyagent/services/tts.pyagent/services/video_reviewer.pyagent/worker/processor.pyextension/background.jstests/unit/test_cli_providers.pytests/unit/test_processor.pytests/unit/test_setup.pytests/unit/test_video_reviewer.pytests/unit/test_youtube.py(New)tools/review_server.pyyoutube/__init__.py(New)youtube/auth.py(New)youtube/upload.py(New)