Files
tenant-registry/internal
sharang 635080c2fe fix(audit): strip IPv6 brackets before INET insert
When a client connects over IPv6 loopback, net/http's RemoteAddr is
'[::1]:port'. The previous clientIP() returned '[::1]' (brackets and
all) which Postgres's INET type rejects:
'invalid input syntax for type inet: "[::1]" (SQLSTATE 22P02)'.

Live local-smoke caught this — every state-changing endpoint emitted
the audit event, the AppendAudit INSERT rolled back, and the warning
landed in the structured log. User-facing operation succeeded so the
caller never noticed; the audit_log table stayed empty.

Fix:
  - Use net.SplitHostPort which returns IPv6 hosts without brackets.
  - Add stripBrackets() as a belt-and-braces for X-Forwarded-For
    headers that wrap the IP themselves (some proxies do).

Refs: M4.2
2026-05-19 17:04:36 +02:00
..