fix(comm): handle null next_action fields in lead creation
BOC CI/CD / Test (push) Failing after 2s
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 11:07:36 +00:00
parent 447ce6f713
commit 9b29841ef4
3 changed files with 10 additions and 2 deletions
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
+10 -2
View File
@@ -90,6 +90,8 @@ func (h *LeadHandler) CreateLead(w http.ResponseWriter, r *http.Request) {
sourceMetadata, _ := json.Marshal(req.SourceMetadata)
var lead Lead
var nextActionAt *time.Time
var nextActionType sql.NullString
err := h.db.QueryRow(`
INSERT INTO leads (tenant_id, contact_id, conversation_id, source, source_metadata,
interest, product, urgency, customer_type, tags, status)
@@ -101,9 +103,15 @@ func (h *LeadHandler) CreateLead(w http.ResponseWriter, r *http.Request) {
req.Interest, req.Product, req.Urgency, req.CustomerType, nullStringArray(req.Tags)).Scan(
&lead.ID, &lead.TenantID, &lead.ContactID, &lead.ConversationID, &lead.Source, &lead.Status,
&lead.Interest, &lead.Product, &lead.Urgency, &lead.CustomerType, &lead.Owner,
&lead.LeadScore, &lead.QualificationComplete, &lead.LastInteractionAt, &lead.NextActionAt,
&lead.NextActionType, &lead.Tags, &lead.CreatedAt, &lead.UpdatedAt,
&lead.LeadScore, &lead.QualificationComplete, &lead.LastInteractionAt, &nextActionAt,
&nextActionType, &lead.Tags, &lead.CreatedAt, &lead.UpdatedAt,
)
if nextActionAt != nil {
lead.NextActionAt = nextActionAt
}
if nextActionType.Valid {
lead.NextActionType = nextActionType.String
}
if err != nil {
log.Error().Err(err).Msg("Failed to create lead")
writeError(w, http.StatusInternalServerError, "failed to create lead")