fix: clarify unavailable legacy blocker resolution

This commit is contained in:
gti
2026-09-22 21:42:24 -03:00
parent c23782095c
commit 50254772e4
7 changed files with 141 additions and 9 deletions
+10 -1
View File
@@ -15,6 +15,11 @@ WORKFLOW_SCOPES = {"PRODUCT", "GROUP", "COMPANY"}
ENTRY_FIELDS = {"scope", "scope_key", "key", "value", "reason"}
MAX_VALUE_LENGTH = 512
MAX_REASON_LENGTH = 2000
MAX_COMPANY_KEY_LENGTH = 64
class BlockerResolutionUnavailable(LookupError):
"""The blocker exists, but has no proven installation to target safely."""
def validate_resolution_input(payload):
@@ -87,12 +92,16 @@ def resolve_blocker_with_context(session, blocker_id, admin, payload, request_ip
if agent.tenant_id != blocker.tenant_id:
raise LookupError("blocker agent tenant mismatch")
else:
raise LookupError("blocker installation is required")
raise BlockerResolutionUnavailable(
"Blocker legado de empresa sem vínculo comprovado com um servidor; não é possível oferecer o reprocessamento de contexto com segurança."
)
tenant = session.get(Tenant, blocker.tenant_id)
company_key = _company_key(blocker, installation, tenant)
if not company_key:
raise ValueError("company context is unavailable")
if len(company_key) > MAX_COMPANY_KEY_LENGTH:
raise ValueError(f"company key must be at most {MAX_COMPANY_KEY_LENGTH} characters")
if normalized["scope"] == "PRODUCT" and normalized["scope_key"] != blocker.product_code:
raise ValueError("PRODUCT scope_key must match the blocker product code")