fix(stream): end close-out pre-flights lifeCycleStatus — no more 403 invalidTransition noise on every stop
startup.log 2026-09-22 (user runs of the new build): ALL THREE session stops
logged 'Broadcast transition(complete) failed (403) invalidTransition → End
close-out: enableAutoStop will finish'. The old ai.md assumption ('invalidTransition
when autoStop already fired') was wrong — the blind complete POST races
YouTube/autoStop marking the broadcast complete (enableAutoStop=true is always
set, tests included), so a blind POST earned only the 403 + log noise. Per the
transition errors table, invalidTransition is a current-status problem and
complete is not gated on streamStatus (only testing/live are):
https://developers.google.com/youtube/v3/live/docs/liveBroadcasts/transition
Fix: EndBroadcastAsync pre-flights liveBroadcasts.list -> status.lifeCycleStatus
and skips the POST when the broadcast is already complete/revoked; an inconclusive
pre-check still posts (old behavior) rather than silently stranding a live
broadcast; still never throws (enableAutoStop finishes every skip).
Good Dog: EndBroadcast test rewritten to the one contract — live -> GET pre-check
+ POST transition (URL shape asserted); already complete -> zero transition POSTs;
inconclusive pre-check + 403 POST -> error string, never a throw. Full suite
315/315 (one-run audio/mouse timing flakes cleared), build 0 warnings.
Recipe recorded in MyMistakes.md; ai.md / Services index / TASK-9 note corrected.
This commit is contained in:
@@ -15,6 +15,19 @@
|
||||
|
||||
## 🔬 Recipes registry
|
||||
|
||||
### TRANSITION(COMPLETE) RACES AUTOSTOP: PRE-FLIGHT lifeCycleStatus (RECIPE)
|
||||
|
||||
A blind `liveBroadcasts.transition?broadcastStatus=complete` POST can 403
|
||||
`invalidTransition` even though the stream just ended normally — 2026-09-22 logged
|
||||
it on EVERY session end. Cause: the broadcast's own state moves toward complete
|
||||
via `enableAutoStop`/YouTube auto-complete; the transition method's errors doc
|
||||
(https://developers.google.com/youtube/v3/live/docs/liveBroadcasts/transition)
|
||||
shows `invalidTransition` = "can't transition from its current status". A blind
|
||||
POST just races — read the broadcast's `lifeCycleStatus` first
|
||||
(`liveBroadcasts.list?part=status`) and only POST complete from `live`/`testing`;
|
||||
skip silently otherwise and let `enableAutoStop` finish it. Never throw on the
|
||||
close-out either way.
|
||||
|
||||
### YOUTUBE liveStreams LIST: healthStatus IS AN OBJECT, NOT A STRING (RECIPE)
|
||||
|
||||
YouTube Data API v3 `liveStreams.list` nests health under
|
||||
|
||||
Reference in New Issue
Block a user