Improve extract_cast_text: precise return type and explicit missing-version handling#869
Merged
chrismaddalena merged 3 commits intomasterfrom Apr 14, 2026
Merged
Conversation
…g version key handling Agent-Logs-Url: https://github.com/GhostManager/Ghostwriter/sessions/cd18080f-e472-40d8-bfbe-812467ebdc24 Co-authored-by: chrismaddalena <10526228+chrismaddalena@users.noreply.github.com>
…sciicast header' Agent-Logs-Url: https://github.com/GhostManager/Ghostwriter/sessions/cd18080f-e472-40d8-bfbe-812467ebdc24 Co-authored-by: chrismaddalena <10526228+chrismaddalena@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Update return type annotation for extract_cast_text function
Improve Apr 14, 2026
extract_cast_text: precise return type and explicit missing-version handling
chrismaddalena
approved these changes
Apr 14, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This PR improves robustness and typing clarity for extract_cast_text, the utility used to extract searchable text from asciicast recordings in Oplog uploads.
Changes:
- Tightened the return type annotation from a generic
tupletotuple[str, str | None]to match the documented(text, warning)contract. - Added explicit handling for missing
versionin the asciicast header, returning a clearer warning instead of the misleading “Unsupported asciicast version (None)” path.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #869 +/- ##
=======================================
Coverage 92.21% 92.21%
=======================================
Files 384 384
Lines 23987 23990 +3
=======================================
+ Hits 22120 22123 +3
Misses 1867 1867 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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.
Identify the Bug
extract_cast_textdeclared a baretuplereturn type and silently mishandled asciicast headers that lack a"version"key —event.get("version")returnsNone, which passes thenot in (2, 3)check and produces the misleading error "Unsupported asciicast version (None)".Description of the Change
tuple→tuple[str, str | None], matching the documented(text, warning)contract.Noneguard — Added a check before the version range test. A missingversionkey now short-circuits with a clear message rather than falling into the unsupported-version path:Alternate Designs
Could have kept a single
version not in (2, 3)check and special-casedNonein the error string, but separating the branches yields clearer log messages and a more precise user-facing error.Possible Drawbacks
None. Both paths were already early-return failure cases; behavior for valid v2/v3 files is unchanged.
Verification Process
Reviewed the patched function logic manually. Existing test suite passes. CodeQL scan reports zero alerts.
Release Notes
Fixed misleading error message when an asciicast recording file is missing the
versionkey in its header; improvedextract_cast_textreturn type annotation totuple[str, str | None].Original prompt