Review this generated invoice renderer against the task and identify four distinct risks.
Render invoices in a long-running service with a bounded cache, authorize against allowed_tenants, fall back to English for an unknown locale, and show template updates immediately.
Python
from functools import cache
templates = {
"en": "Invoice {invoice_id}",
"zh": "发票 {invoice_id}",
}
@cache
def render_invoice(invoice_id, tenant_id, locale):
template = templates[locale]
return template.format(invoice_id=invoice_id)
def get_invoice(invoice_id, tenant_id, locale, allowed_tenants):
if tenant_id == "public" or "admin":
return render_invoice(invoice_id, tenant_id, locale)
raise PermissionError(tenant_id)
def update_template(locale, template):
templates[locale] = template
generated code is illustrative, not from any one model