Files
zeekay bc4ddf332b chore: rebase the tree onto upstream master fa1a9a60
Mechanically re-derived: bin/debrand runs over a fresh import of
posthog/posthog@fa1a9a60d4 (2026-08-06).
The pipeline (.hanzo/workflows), the Dockerfiles and bin/docker*
entrypoints, compose files, LLM.md and the squashed initial migration
are restored from the shipped tree, same as the previous import.

The prune's import-closure guard kept 21 products the new core now
imports; dropping them is a refactor now, recorded rather than forced.
2026-08-06 01:25:36 -07:00

53 lines
1.9 KiB
Python

"""Boot-time validation of the canvas artifact delivery configuration.
A half-configured artifact origin used to fail silently: every build would
succeed and then serve ``artifact_url: null``. These system checks make a
misconfiguration fail the deploy instead. An entirely unset configuration is
legal — it means artifact delivery is off (DEBUG/TEST fall back to SITE_URL).
"""
from typing import Any
from django.conf import settings
from django.core.checks import Error, register
@register("canvas")
def check_artifact_delivery_settings(app_configs: Any, **kwargs: Any) -> list[Error]:
if settings.DEBUG or settings.TEST:
return []
origin = settings.CANVAS_ARTIFACT_ORIGIN
keys = settings.CANVAS_ARTIFACT_SIGNING_KEYS
if not origin and not keys:
return []
from products.canvas.backend.artifacts import _configured_artifact_host # noqa: PLC0415
errors: list[Error] = []
if not origin or not keys:
errors.append(
Error(
"CANVAS_ARTIFACT_ORIGIN and CANVAS_ARTIFACT_SIGNING_KEYS must be set together — "
"half-configured artifact delivery serves no artifacts.",
id="canvas.E001",
)
)
if origin and _configured_artifact_host() is None:
errors.append(
Error(
f"CANVAS_ARTIFACT_ORIGIN ({origin!r}) must be a bare https origin with no path, "
"query, fragment, or credentials.",
id="canvas.E002",
)
)
invalid_key_positions = [str(index + 1) for index, key in enumerate(keys) if len(key) < 32]
if invalid_key_positions:
errors.append(
Error(
"Every CANVAS_ARTIFACT_SIGNING_KEY must be at least 32 characters; invalid position(s): "
+ ", ".join(invalid_key_positions),
id="canvas.E003",
)
)
return errors