Skip to content

fix(subtitle): unify create() return value and check result in caller - #1244

Open
yu3394 wants to merge 1 commit into
harry0703:mainfrom
yu3394:fix/subtitle-create-return-consistency
Open

fix(subtitle): unify create() return value and check result in caller#1244
yu3394 wants to merge 1 commit into
harry0703:mainfrom
yu3394:fix/subtitle-create-return-consistency

Conversation

@yu3394

@yu3394 yu3394 commented Aug 22, 2026

Copy link
Copy Markdown
  • Add return type annotation -> str to subtitle.create()
  • Return empty string instead of None when model loading fails, consistent with import failure
  • Return subtitle_file path on success so callers can verify generation
  • Check create() return value in task.py before calling correct(), skip correction and return early on failure

- Add return type annotation -> str to subtitle.create()
- Return empty string instead of None when model loading fails, consistent with import failure
- Return subtitle_file path on success so callers can verify generation
- Check create() return value in task.py before calling correct(), skip correction and return early on failure
@harry0703

Copy link
Copy Markdown
Owner

Thank you for fixing the inconsistent Whisper subtitle result contract. The production change is small and the caller-side guard is the right direction, but the PR is not yet merge-ready because the repository tests were not updated with the new contract.

My local run reports 2 failures, 53 passes, and 3 skips:

  • test_create_returns_none_when_whisper_model_cannot_load still expects None instead of the new empty-string failure value.
  • test_generate_subtitle_uses_whisper_for_custom_audio_without_sub_maker uses a successful fake create() that writes the SRT but returns None; the new caller therefore treats it as failure and skips correction.

Please update those tests, make the successful fake return subtitle_file, and add explicit coverage that an empty create() result skips correct() and returns an empty subtitle path. It would also be useful to assert that a successful real/fake create() returns the generated path. Ruff already passes.

Thanks again—once the tests reflect the new contract, this should be a low-risk reliability improvement.

LiamVisionary added a commit to LiamVisionary/hivemind-content-studio that referenced this pull request Aug 28, 2026
From upstream harry0703/MoneyPrinterTurbo#1244 by @yu3394 — the only one of the
seven PRs open there that still applies to this fork.

`subtitle.create()` returned `None` when the Whisper model could not load and
nothing at all on success, and the caller ignored both. So on a machine where
Whisper is unavailable the run went straight on to `subtitle.correct()` over a
path that was never written — and that does not raise, because
`file_to_subtitles` answers `[]` for a missing file. The result was a finished
video with no subtitles, no error, and a log line reading "correcting subtitle"
as though it had worked.

It returns the path it wrote now, `""` when it wrote nothing, and the caller
stops rather than correcting a file that does not exist.

Two existing tests pinned the old shape and are updated rather than deleted.
`test_create_returns_none_...` asserted `None` while its own docstring asked
only for "a failure result the task layer can act on", so it now asserts the
failure result and not which falsy value carries it. And the Whisper fake in
test_task.py wrote its file but returned nothing, which is a fake of the old
contract and now reads to the caller as a failure — it returns the path.

One test of my own, and it took two goes to make it worth having: the first
version set `subtitle_provider` on the params stub, but that is read from
`config.app`, so the test took the `edge` branch and returned early. It passed
with the fix and without it. It patches the config now, and fails without the
change.

The other six upstream PRs do not apply: this fork has rewritten the files they
patch, and their own patches fail on 4 to 31 hunks each.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants