unslothai/unsloth · error · RuntimeError

sd-server img_gen submit -> {resp.status_code}: {resp.text[:

Error message

sd-server img_gen submit -> {resp.status_code}: {resp.text[:500]}

What it means

The img_gen submit endpoint returned an unexpected status code — anything other than 200, 202 (success paths) or 429 (handled separately as queue-full). The message embeds the status code and the first 500 chars of the response body, which is the key diagnostic. Typical causes are 400/422 for invalid payloads or 5xx for server-side errors.

Source

Thrown at studio/backend/core/inference/sd_cpp_server.py:468

        if self._stopped or not self.is_alive():
            if cancel_event is not None and cancel_event.is_set():
                raise SdCppCancelled("sd-server generation was cancelled.")
            raise RuntimeError("sd-server is not running.")

        self._step_listener = on_step
        job_id: Optional[str] = None
        try:
            # Submit -> 202 Accepted + job id.
            try:
                resp = self._client.post(
                    f"{self.base_url}{_IMG_GEN_PATH}", json = payload, timeout = submit_timeout
                )
            except (*_TRANSPORT_ERRORS, httpx.TimeoutException) as exc:
                raise RuntimeError(self._died_message("img_gen submit", exc)) from exc
            if resp.status_code == 429:
                raise RuntimeError("sd-server job queue is full (HTTP 429).")
            if resp.status_code not in (200, 202):
                raise RuntimeError(
                    f"sd-server img_gen submit -> {resp.status_code}: {resp.text[:500]}"
                )
            try:
                job = resp.json()
            except ValueError as exc:
                raise RuntimeError(
                    f"sd-server img_gen returned a non-JSON submit response: {exc}"
                ) from exc
            if not isinstance(job, dict):
                raise RuntimeError(
                    f"sd-server img_gen returned an unexpected submit response type: {type(job)}"
                )
            job_id = job.get("id")
            if not job_id:
                raise RuntimeError(f"sd-server img_gen returned no job id: {job}")

            # Poll the job to a terminal state.
            deadline = time.monotonic() + total_timeout

View on GitHub (pinned to 203007d190)

Solutions

  1. Read the embedded status + body fragment: a 4xx names the invalid field; a 5xx means a server bug/crash — check server logs.
  2. Update both sides together (server and wrapper ship as one runtime; re-run `unsloth studio update`) to remove schema skew.
  3. If constructing payloads manually, validate field names/types against the server's API before submitting.
Defensive patterns

Strategy: try-catch

Try / catch

try:
    blobs = server.img_gen(payload, ...)
except RuntimeError as e:
    if "img_gen submit ->" in str(e):
        log_payload_schema_error(str(e))  # body names the invalid field
    raise

Prevention

When it happens

Trigger: Submitting a payload the server rejects (unknown model field, out-of-range params, unsupported sampler) producing 400/422; server internal error (500) during job creation.

Common situations: Version skew between client wrapper and server (payload schema changed after an update); hand-built payloads with wrong field names or types.

Related errors


AI-assisted analysis of unslothai/unsloth@203007d190 (2026-08-15). Data as JSON: /api/errors/1cda5ee048b9ee67. Report an issue: GitHub.