calesthio/OpenMontage · error · ValueError

Kling identify-face response missing data.session_id: {data}

Error message

Kling identify-face response missing data.session_id: {data}

What it means

ValueError from KlingLipSyncTool._identify_faces when the POST to /v1/videos/identify-face succeeds but the response's data object has no session_id. The session_id is the handle for the subsequent advanced-lip-sync call, so without it the flow cannot continue. Its absence means the gateway returned an error- or auth-shaped payload with HTTP 200, or a schema variant.

Source

Thrown at tools/avatar/kling_lip_sync.py:263

                data.update(
                    {
                        "error_code": exc.code,
                        "request_id": exc.request_id,
                        "http_status": exc.http_status,
                        "account_usage_diagnostic": account_usage_hint_for_error(exc),
                    }
                )
            return ToolResult(success=False, data=data, error=f"Kling official lip-sync failed: {exc}")
        except Exception as exc:
            return ToolResult(success=False, data={"provider": self.provider}, error=f"Kling official lip-sync failed: {exc}")

    def _identify_faces(self, client: KlingClient, inputs: dict[str, Any]) -> dict[str, Any]:
        request = self._build_identify_request(inputs)
        data = client.post(request["path"], request["payload"])
        payload = data.get("data") or {}
        session_id = payload.get("session_id")
        if not session_id:
            raise ValueError(f"Kling identify-face response missing data.session_id: {data}")
        faces = (
            payload.get("face_data")
            or payload.get("faces")
            or payload.get("face_list")
            or payload.get("face_infos")
            or payload.get("faces_info")
            or []
        )
        if not isinstance(faces, list):
            raise ValueError("Kling identify-face response face list is not a list")
        if not faces:
            raise ValueError("Kling identify-face response contained no faces")
        return {
            "session_id": str(session_id),
            "faces": faces,
            "raw_response": data,
            "request": request,
        }

View on GitHub (pinned to 95e1c3d0ab)

Solutions

  1. Inspect the full response JSON printed in the message to identify whether it is an auth/quota error or a schema difference.
  2. Verify the Kling access key/secret and account quota.
  3. If the key is camelCase in your gateway's responses, add payload.get('sessionId') to the extraction in _identify_faces.

Example fix

// before
session_id = payload.get("session_id")

// after
session_id = payload.get("session_id") or payload.get("sessionId")
Defensive patterns

Strategy: try-catch

Try / catch

try:
    identify = tool._identify_faces(client, inputs)
except ValueError as e:
    if "missing data.session_id" in str(e):
        # raw response is in the message; diagnose auth/quota/schema and raise a clear error
        raise

Prevention

When it happens

Trigger: Calling kling_lip_sync with operation='identify_face' (or the auto flow) while the API key is invalid, quota is exhausted, or the gateway nests session_id under a different key than data.session_id.

Common situations: Expired Kling API key; free-tier quota for face identification used up; gateway version returning 'sessionId' camelCase instead of session_id.

Related errors


AI-assisted analysis of calesthio/OpenMontage@95e1c3d0ab (2026-08-15). Data as JSON: /api/errors/767785bb75501f83. Report an issue: GitHub.