{"record":{"id":"767785bb75501f83","repo":"calesthio/OpenMontage","slug":"kling-identify-face-response-missing-data-session","errorCode":null,"errorMessage":"Kling identify-face response missing data.session_id: {data}","messagePattern":"Kling identify-face response missing data\\.session_id: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"tools/avatar/kling_lip_sync.py","lineNumber":263,"sourceCode":"                data.update(\n                    {\n                        \"error_code\": exc.code,\n                        \"request_id\": exc.request_id,\n                        \"http_status\": exc.http_status,\n                        \"account_usage_diagnostic\": account_usage_hint_for_error(exc),\n                    }\n                )\n            return ToolResult(success=False, data=data, error=f\"Kling official lip-sync failed: {exc}\")\n        except Exception as exc:\n            return ToolResult(success=False, data={\"provider\": self.provider}, error=f\"Kling official lip-sync failed: {exc}\")\n\n    def _identify_faces(self, client: KlingClient, inputs: dict[str, Any]) -> dict[str, Any]:\n        request = self._build_identify_request(inputs)\n        data = client.post(request[\"path\"], request[\"payload\"])\n        payload = data.get(\"data\") or {}\n        session_id = payload.get(\"session_id\")\n        if not session_id:\n            raise ValueError(f\"Kling identify-face response missing data.session_id: {data}\")\n        faces = (\n            payload.get(\"face_data\")\n            or payload.get(\"faces\")\n            or payload.get(\"face_list\")\n            or payload.get(\"face_infos\")\n            or payload.get(\"faces_info\")\n            or []\n        )\n        if not isinstance(faces, list):\n            raise ValueError(\"Kling identify-face response face list is not a list\")\n        if not faces:\n            raise ValueError(\"Kling identify-face response contained no faces\")\n        return {\n            \"session_id\": str(session_id),\n            \"faces\": faces,\n            \"raw_response\": data,\n            \"request\": request,\n        }","sourceCodeStart":245,"sourceCodeEnd":281,"githubUrl":"https://github.com/calesthio/OpenMontage/blob/95e1c3d0ab93482159818560f6a8c8e866b9139f/tools/avatar/kling_lip_sync.py#L245-L281","documentation":"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.","triggerScenarios":"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.","commonSituations":"Expired Kling API key; free-tier quota for face identification used up; gateway version returning 'sessionId' camelCase instead of session_id.","solutions":["Inspect the full response JSON printed in the message to identify whether it is an auth/quota error or a schema difference.","Verify the Kling access key/secret and account quota.","If the key is camelCase in your gateway's responses, add payload.get('sessionId') to the extraction in _identify_faces."],"exampleFix":"// before\nsession_id = payload.get(\"session_id\")\n\n// after\nsession_id = payload.get(\"session_id\") or payload.get(\"sessionId\")","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try:\n    identify = tool._identify_faces(client, inputs)\nexcept ValueError as e:\n    if \"missing data.session_id\" in str(e):\n        # raw response is in the message; diagnose auth/quota/schema and raise a clear error\n        raise","preventionTips":["Verify the Kling API key and quota before starting the identify/advanced flow","Integration-test against the exact gateway endpoint you will use in production"],"tags":["kling","lip-sync","api-response","schema-mismatch","authentication"],"backgroundTag":null,"analyzedSha":"95e1c3d0ab93482159818560f6a8c8e866b9139f","analyzedAt":"2026-08-15T06:31:20.014Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}