fix(comm): handle null tags array in contact creation
BOC CI/CD / Test (push) Failing after 14s
BOC CI/CD / Security Scan (push) Has been skipped
BOC CI/CD / Build & Push (push) Has been skipped
BOC CI/CD / Deploy to Staging (push) Has been skipped
BOC CI/CD / Deploy to Production (push) Has been skipped

This commit is contained in:
Bernt
2026-08-12 10:45:16 +00:00
parent 848be51332
commit 417903b488
3 changed files with 11 additions and 3 deletions
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
+11 -3
View File
@@ -206,10 +206,11 @@ func (h *ContactHandler) createNewContact(tenantID uuid.UUID, req CreateContactR
err := h.db.QueryRow(`
INSERT INTO contacts (tenant_id, first_name, last_name, email, phone, company, source, tags, metadata)
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9)
RETURNING id, tenant_id, first_name, last_name, email, phone, company, tags, status, lead_score, source, created_at, updated_at
`, tenantID, req.FirstName, req.LastName, req.Email, req.Phone, req.Company, req.Source, req.Tags, metadata).Scan(
RETURNING id, tenant_id, first_name, last_name, email, phone, company, status, lead_score, source, created_at, updated_at
`, tenantID, req.FirstName, req.LastName, req.Email, req.Phone, req.Company, req.Source,
nullStringArray(req.Tags), metadata).Scan(
&contact.ID, &contact.TenantID, &contact.FirstName, &contact.LastName, &contact.Email, &contact.Phone,
&contact.Company, &contact.Tags, &contact.Status, &contact.LeadScore, &contact.Source, &contact.CreatedAt, &contact.UpdatedAt,
&contact.Company, &contact.Status, &contact.LeadScore, &contact.Source, &contact.CreatedAt, &contact.UpdatedAt,
)
return &contact, err
@@ -260,3 +261,10 @@ func getTenantID(r *http.Request) uuid.UUID {
// Fallback: fixed tenant för utveckling
return uuid.MustParse("3847477b-3d56-4975-9157-ae8f9ce52aa7")
}
func nullStringArray(arr []string) interface{} {
if len(arr) == 0 {
return nil
}
return arr
}