{"record":{"id":"94598a54cbbfbc4b","repo":"BerriAI/litellm","slug":"standard-logging-object-not-found-in-kwargs","errorCode":null,"errorMessage":"standard_logging_object not found in kwargs","messagePattern":"standard_logging_object not found in kwargs","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/integrations/datadog/datadog.py","lineNumber":576,"sourceCode":"        start_time: datetime.datetime,\n        end_time: datetime.datetime,\n    ) -> DatadogPayload:\n        \"\"\"\n        Helper function to create a datadog payload for logging\n\n        Args:\n            kwargs (Union[dict, Any]): request kwargs\n            response_obj (Any): llm api response\n            start_time (datetime.datetime): start time of request\n            end_time (datetime.datetime): end time of request\n\n        Returns:\n            DatadogPayload: defined in types.py\n        \"\"\"\n\n        standard_logging_object: Final[StandardLoggingPayload | None] = kwargs.get(\"standard_logging_object\", None)\n        if standard_logging_object is None:\n            raise ValueError(\"standard_logging_object not found in kwargs\")\n\n        status = DataDogStatus.INFO\n        if standard_logging_object.get(\"status\") == \"failure\":\n            status = DataDogStatus.ERROR\n\n        # Build the initial payload\n        self.truncate_standard_logging_payload_content(standard_logging_object)\n\n        dd_payload: Final = self._create_datadog_logging_payload_helper(\n            standard_logging_object=standard_logging_object,\n            status=status,\n        )\n        return dd_payload\n\n    async def async_send_compressed_data(self, data: list) -> Response:\n        \"\"\"\n        Async helper to send compressed data to datadog self.intake_url\n","sourceCodeStart":558,"sourceCodeEnd":594,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/integrations/datadog/datadog.py#L558-L594","documentation":"create_datadog_logging_payload builds the Datadog payload from kwargs[\"standard_logging_object\"], a StandardLoggingPayload that litellm's core logging machinery attaches to every log_success_event/log_failure_event call. If the key is absent it raises ValueError immediately. In the normal litellm.completion/proxy flow this object is always populated, so hitting it almost always means the payload builder was invoked outside litellm's logging pipeline.","triggerScenarios":"Calling logger.create_datadog_logging_payload(kwargs, ...) directly in unit tests or custom code with hand-built kwargs; manually invoking log_success_event with a fabricated kwargs dict; a litellm version mismatch where an older core does not yet attach standard_logging_object before invoking callbacks.","commonSituations":"Teams unit-testing callback classes by constructing kwargs themselves instead of running a real completion; mixed-version installs (callback class from newer litellm, core from older one); copy-pasted example code that calls payload builders directly.","solutions":["Trigger logging through the real flow: litellm.completion(..., callbacks=[DatadogLogger(...)]) so the core populates standard_logging_object","If you must build payloads directly, construct kwargs via litellm's own helpers (get_standard_logging_payload) or attach a valid StandardLoggingPayload before calling","Reinstall litellm as one consistent version so callback and core agree"],"exampleFix":"# before\nkwargs = {\"model\": \"gpt-4\", \"messages\": [...]}\npayload = logger.create_datadog_logging_payload(kwargs, response_obj, start, end)  # ValueError\n\n# after\nimport litellm\nresp = litellm.completion(model=\"gpt-4\", messages=[...], callbacks=[logger])\n# standard_logging_object is attached internally; payload building happens in the hook","handlingStrategy":"validation","validationCode":"def has_standard_logging_object(kwargs: dict) -> bool:\n    \"\"\"Caller-side guard before touching datadog payload builders directly.\"\"\"\n    slo = kwargs.get(\"standard_logging_object\")\n    return isinstance(slo, dict) and len(slo) > 0","typeGuard":"from typing import Any\nfrom litellm.integrations.datadog.types import DatadogPayload\n\ndef is_logging_kwargs(kwargs: Any) -> bool:\n    \"\"\"Narrow kwargs to the shape create_datadog_logging_payload requires.\"\"\"\n    return isinstance(kwargs, dict) and isinstance(kwargs.get(\"standard_logging_object\"), dict)","tryCatchPattern":"try:\n    payload = logger.create_datadog_logging_payload(kwargs, resp, start, end)\nexcept ValueError as e:\n    if \"standard_logging_object\" in str(e):\n        raise RuntimeError(\"called outside litellm logging flow; pass kwargs from a real completion\") from e\n    raise","preventionTips":["Never hand-build kwargs for payload builders; capture real kwargs from a hook","Pin one litellm version so callback/core contracts stay in sync","In tests, fixture a recorded StandardLoggingPayload instead of an empty dict"],"tags":["datadog","logging","kwargs","internal-api","misuse"],"backgroundTag":"missing-required-argument","analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}