{"record":{"id":"ad7e7273bac33f78","repo":"calesthio/OpenMontage","slug":"callback-url-must-be-an-absolute-http-s-url","errorCode":null,"errorMessage":"callback_url must be an absolute http(s) URL","messagePattern":"callback_url must be an absolute http\\(s\\) URL","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"tools/_kling/callbacks.py","lineNumber":16,"sourceCode":"\"\"\"Callback validation helpers for Kling official providers.\"\"\"\n\nfrom __future__ import annotations\n\nfrom urllib.parse import urlparse\n\n\ndef validate_callback_url(callback_url: str | None) -> str | None:\n    \"\"\"Return a normalized callback URL or raise for obviously invalid input.\"\"\"\n\n    if not callback_url:\n        return None\n    value = str(callback_url).strip()\n    parsed = urlparse(value)\n    if parsed.scheme not in {\"http\", \"https\"} or not parsed.netloc:\n        raise ValueError(\"callback_url must be an absolute http(s) URL\")\n    return value\n","sourceCodeStart":1,"sourceCodeEnd":18,"githubUrl":"https://github.com/calesthio/OpenMontage/blob/95e1c3d0ab93482159818560f6a8c8e866b9139f/tools/_kling/callbacks.py#L1-L18","documentation":"ValueError raised by validate_callback_url when a non-empty callback_url parses without an http/https scheme or without a netloc. It is a cheap, dependency-free pre-flight check: Kling will silently ignore or reject malformed webhook URLs, so obviously-invalid input is caught client-side before any API call. Empty/None passes through as None (callback disabled).","triggerScenarios":"Passing callback_url values like 'kling-hook.example.com/webhook' (no scheme), 'http://' (no host), 'file:///tmp/x', relative paths, or values with leading whitespace that still strip to scheme-less strings.","commonSituations":"Config files storing the webhook without https:// because the ingress adds it later; localhost URLs typed without scheme during local testing; template interpolation producing empty host ('https://${HOST}/hook' with unset HOST); copying a path-only webhook route from docs.","solutions":["Set the value to a fully-qualified absolute URL: https://host.example.com/path","Check template/env interpolation actually produced the host before building the URL","For local testing use a tunnel (ngrok/cloudflared) and pass its absolute https URL — Kling must be able to reach the callback","Leave callback_url unset/None when no callback is needed — that is a valid no-callback path"],"exampleFix":"# before\nvalidate_callback_url(\"kling-hooks.example.com/cb\")  # raises\n\n# after\nvalidate_callback_url(\"https://kling-hooks.example.com/cb\")  # ok","handlingStrategy":"validation","validationCode":"from urllib.parse import urlparse\ndef is_valid_callback_url(url: str | None) -> bool:\n    if not url:\n        return True  # unset is fine\n    p = urlparse(str(url).strip())\n    return p.scheme in {\"http\", \"https\"} and bool(p.netloc)\n\nif not is_valid_callback_url(callback_url):\n    raise SystemExit(\"callback_url must be absolute http(s), e.g. https://host/hook\")","typeGuard":"def is_valid_callback_url(url: str | None) -> bool:\n    if not url:\n        return True\n    p = urlparse(str(url).strip())\n    return p.scheme in {\"http\", \"https\"} and bool(p.netloc)","tryCatchPattern":"try:\n    validate_callback_url(callback_url)\nexcept ValueError:\n    raise SystemExit(\"fix callback_url: include scheme and host, or unset it\")","preventionTips":["Build callback URLs with a base URL from config, never string-concat paths alone","Assert interpolated env vars (host) are non-empty before composing the URL","Use a tunnel for local webhook testing; Kling must reach the callback"],"tags":["kling","callback","url-validation","pre-flight"],"backgroundTag":null,"analyzedSha":"95e1c3d0ab93482159818560f6a8c8e866b9139f","analyzedAt":"2026-08-15T06:31:20.014Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}