Skip to content

AI turns documents or topics into real, native PowerPoint decks—with native shapes, transitions and animations, data-backed charts and tables on demand, audio narration from speaker notes, and support for your own .pptx templates. · by Hugo He

fix(image-generation): stop manifest batches on global backend failures

hugohe32e095090a6e9
diff --git a/skills/ppt-master/scripts/image_backends/backend_common.py b/skills/ppt-master/scripts/image_backends/backend_common.py
index ac8c9f91..a7b7eae9 100644
--- a/skills/ppt-master/scripts/image_backends/backend_common.py
+++ b/skills/ppt-master/scripts/image_backends/backend_common.py
@@ -40,14 +40,16 @@ RETRY_BACKOFF = 2
_TRANSIENT_CLIENT_STATUSES = {408, 409, 423, 425, 429}
_HTTP_ERROR_STATUS = re.compile(r"\(([1-5][0-9]{2})\):")
-_PERMANENT_ERROR_TYPES = {
+_GLOBAL_PERMANENT_ERROR_TYPES = {
"authenticationerror",
+}
+_ITEM_PERMANENT_ERROR_TYPES = {
"badrequesterror",
"notfounderror",
"permissiondeniederror",
"unprocessableentityerror",
}
-_PERMANENT_ERROR_MARKERS = (
+_GLOBAL_PERMANENT_ERROR_MARKERS = (
"prepayment credits are depleted",
"prepaid credits are depleted",
"credits are depleted",
@@ -63,9 +65,19 @@ _PERMANENT_ERROR_MARKERS = (
"invalid api key",
"api key not valid",
"incorrect api key",
+ "no api key found",
+ "missing api key",
+ "api key required",
+ "api key is required",
+ "api key not set",
+ "api key is not set",
+ "api key expired",
+ "expired api key",
"authentication failed",
"authentication required",
"unauthorized",
+)
+_ITEM_PERMANENT_ERROR_MARKERS = (
"permission denied",
"forbidden",
"invalid_argument",
@@ -347,10 +359,29 @@ def _error_status_code(exc: Exception) -> int | None:
return int(match.group(1)) if match else None
+def is_global_permanent_error(exc: Exception) -> bool:
+ """Return whether every unchanged request would fail for this backend."""
+ if isinstance(exc, _RetryableBackendError):
+ return False
+
+ status_code = _error_status_code(exc)
+ if status_code in {401, 402}:
+ return True
+
+ error_name = type(exc).__name__.lower()
+ if error_name in _GLOBAL_PERMANENT_ERROR_TYPES:
+ return True
+
+ err_str = str(exc).lower()
+ return any(marker in err_str for marker in _GLOBAL_PERMANENT_ERROR_MARKERS)
+
+
def is_permanent_error(exc: Exception) -> bool:
"""Return whether retrying the unchanged backend request cannot succeed."""
if isinstance(exc, _RetryableBackendError):
return False
+ if is_global_permanent_error(exc):
+ return True
if isinstance(exc, (FileNotFoundError, NotImplementedError, PermissionError)):
return True
@@ -363,11 +394,11 @@ def is_permanent_error(exc: Exception) -> bool:
return True
error_name = type(exc).__name__.lower()
- if error_name in _PERMANENT_ERROR_TYPES:
+ if error_name in _ITEM_PERMANENT_ERROR_TYPES:
return True
err_str = str(exc).lower()
- return any(marker in err_str for marker in _PERMANENT_ERROR_MARKERS)
+ return any(marker in err_str for marker in _ITEM_PERMANENT_ERROR_MARKERS)
def is_rate_limit_error(exc: Exception) -> bool:
diff --git a/skills/ppt-master/scripts/image_gen.py b/skills/ppt-master/scripts/image_gen.py
index d03c8176..1d2e883a 100644
--- a/skills/ppt-master/scripts/image_gen.py
+++ b/skills/ppt-master/scripts/image_gen.py
@@ -876,8 +876,8 @@ def _run_manifest(manifest: dict, manifest_path: str, backend_module, *,
and not retried within this run. `Failed` remains retryable and
non-terminal; the Step 5 gate must resolve it by rerunning this
manifest or marking the item `Needs-Manual`.
- - Permanent auth, billing, model, and request errors skip unchanged
- backend retries but keep the same repairable `Failed` manifest state.
+ - Global auth or billing errors stop new batches; untouched rows remain
+ retryable. Permanent model or request errors fail only their own row.
- Status is written back to the manifest file after each completion;
a Ctrl-C in the middle still preserves done items.
- `Needs-Manual` items are skipped (user processes them externally).
@@ -893,6 +893,7 @@ def _run_manifest(manifest: dict, manifest_path: str, backend_module, *,
output_dir = str(manifest_output_dir)
from image_backends.backend_common import (
+ is_global_permanent_error,
is_permanent_error,
is_rate_limit_error,
validate_image_file,
@@ -943,6 +944,7 @@ def _run_manifest(manifest: dict, manifest_path: str, backend_module, *,
current = max(1, initial_concurrency)
state_lock = threading.Lock()
rate_limit_attempts: dict[int, int] = {}
+ stopped_for_global_error = False
stopped_for_rate_limit = False
def _one(idx: int):
@@ -987,15 +989,21 @@ def _run_manifest(manifest: dict, manifest_path: str, backend_module, *,
ok_count += 1
print(f" [OK] {item['filename']}")
elif isinstance(exc, ValueError) or is_permanent_error(exc):
+ global_error = is_global_permanent_error(exc)
item["status"] = STATUS_FAILED
+ error_scope = "Global" if global_error else "Permanent"
+ repair_target = (
+ "backend access" if global_error else "model or request"
+ )
item["last_error"] = (
- f"Permanent backend error: {exc}"
+ f"{error_scope} backend error: {exc}"
)[:500]
fail_count += 1
+ if global_error:
+ stopped_for_global_error = True
print(
f" [FAIL] {item['filename']}: {exc} "
- "(status=Failed; repair credentials, billing, "
- "model, or request before retry)"
+ f"(status=Failed; repair {repair_target} before retry)"
)
elif is_rate_limit_error(exc):
rate_limited = True
@@ -1038,6 +1046,12 @@ def _run_manifest(manifest: dict, manifest_path: str, backend_module, *,
)
save_manifest(manifest_path, manifest)
+ if stopped_for_global_error:
+ print(
+ "\n Backend authentication or billing requires repair. "
+ "Stopping new batches; untouched items remain retryable.\n"
+ )
+ break
if stopped_for_rate_limit:
print(
"\n Persistent rate limit reached the run boundary. "
@@ -1055,9 +1069,10 @@ def _run_manifest(manifest: dict, manifest_path: str, backend_module, *,
elif queue:
time.sleep(2)
- run_state = "Stopped" if stopped_for_rate_limit else "Done"
+ stopped_early = stopped_for_global_error or stopped_for_rate_limit
+ run_state = "Stopped" if stopped_early else "Done"
remaining_note = ""
- if stopped_for_rate_limit:
+ if stopped_early:
remaining = sum(
1 for item in items if item["status"] in RETRYABLE_STATUSES
)