{"record":{"id":"1cda5ee048b9ee67","repo":"unslothai/unsloth","slug":"sd-server-img-gen-submit-resp-status-code-r","errorCode":null,"errorMessage":"sd-server img_gen submit -> {resp.status_code}: {resp.text[:500]}","messagePattern":"sd-server img_gen submit -> (.+?): (.+?)","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"studio/backend/core/inference/sd_cpp_server.py","lineNumber":468,"sourceCode":"        if self._stopped or not self.is_alive():\n            if cancel_event is not None and cancel_event.is_set():\n                raise SdCppCancelled(\"sd-server generation was cancelled.\")\n            raise RuntimeError(\"sd-server is not running.\")\n\n        self._step_listener = on_step\n        job_id: Optional[str] = None\n        try:\n            # Submit -> 202 Accepted + job id.\n            try:\n                resp = self._client.post(\n                    f\"{self.base_url}{_IMG_GEN_PATH}\", json = payload, timeout = submit_timeout\n                )\n            except (*_TRANSPORT_ERRORS, httpx.TimeoutException) as exc:\n                raise RuntimeError(self._died_message(\"img_gen submit\", exc)) from exc\n            if resp.status_code == 429:\n                raise RuntimeError(\"sd-server job queue is full (HTTP 429).\")\n            if resp.status_code not in (200, 202):\n                raise RuntimeError(\n                    f\"sd-server img_gen submit -> {resp.status_code}: {resp.text[:500]}\"\n                )\n            try:\n                job = resp.json()\n            except ValueError as exc:\n                raise RuntimeError(\n                    f\"sd-server img_gen returned a non-JSON submit response: {exc}\"\n                ) from exc\n            if not isinstance(job, dict):\n                raise RuntimeError(\n                    f\"sd-server img_gen returned an unexpected submit response type: {type(job)}\"\n                )\n            job_id = job.get(\"id\")\n            if not job_id:\n                raise RuntimeError(f\"sd-server img_gen returned no job id: {job}\")\n\n            # Poll the job to a terminal state.\n            deadline = time.monotonic() + total_timeout","sourceCodeStart":450,"sourceCodeEnd":486,"githubUrl":"https://github.com/unslothai/unsloth/blob/203007d19051dcd2ae33876786d117c99f6b0368/studio/backend/core/inference/sd_cpp_server.py#L450-L486","documentation":"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.","triggerScenarios":"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.","commonSituations":"Version skew between client wrapper and server (payload schema changed after an update); hand-built payloads with wrong field names or types.","solutions":["Read the embedded status + body fragment: a 4xx names the invalid field; a 5xx means a server bug/crash — check server logs.","Update both sides together (server and wrapper ship as one runtime; re-run `unsloth studio update`) to remove schema skew.","If constructing payloads manually, validate field names/types against the server's API before submitting."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try:\n    blobs = server.img_gen(payload, ...)\nexcept RuntimeError as e:\n    if \"img_gen submit ->\" in str(e):\n        log_payload_schema_error(str(e))  # body names the invalid field\n    raise","preventionTips":["Update server and client wrapper together as one runtime.","Don't hand-craft payloads; use the wrapper's payload builder.","Log status + body fragment for any non-2xx before retrying blindly."],"tags":["diffusion","sd-cpp","server","http","payload"],"backgroundTag":null,"analyzedSha":"203007d19051dcd2ae33876786d117c99f6b0368","analyzedAt":"2026-08-15T02:48:39.846Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}