Skip to content

Broken and conflicting automation across hooks and flows #489

Description

@yinlianghui

Automation that reads/writes nonexistent fields or never fires

  • src/objects/campaign.hook.ts:73-74 counts crm_lead with filter: { campaign: id }crm_lead has no campaign field. num_leads / num_converted_leads are always 0 (errors swallowed by onError: 'log').
  • src/objects/contact.hook.ts:51,54 writes contact_email / contact_phone to crm_opportunity — neither field exists on the object; the failure is swallowed by catch {}.
  • days_in_stage (opportunity.object.ts:180-184) is written by nothing; only seed data hardcodes it. opportunity-stagnation.flow.ts:41 filters days_in_stage > 14, so the flow only matches seeded demo rows.
  • campaign-enrollment.flow.ts:11-31 is type: 'schedule' (cron 0 9 * * 1) but filters on input variables {campaignId} / {leadStatus} that a scheduled trigger never receives; each run resolves to empty filters.
  • quote.hook.ts:98-128 inserts crm_contract with crm_contact from the quote; crm_quote.crm_contact is optional while crm_contract.crm_contact is required: true. Accepting a contact-less quote fails validation silently (async: true, onError: 'log').
  • knowledge_article.hook.ts:25-27 sets input.published_at = nowIso without checking for a provided value; seeded historical dates (src/data/index.ts:1107,1128,1157) all become the boot date.
  • crm_quote.owner (quote.object.ts:89-93) is the only owner field without defaultValue; demo-bootstrap.flow.ts:76-83 also skips quote/contract/campaign/forecast, so quote_expiration / contract_renewal / contract_expiration notify an empty owner.

Duplicate/conflicting automation on the same events

  • Case escalation creates two follow-up tasks: case.hook.ts:112-128 (priority urgent) and case-escalation.flow.ts:54-65 (priority high).
  • Contract renewal tasks are created twice and daily: contract.hook.ts:132-147 on activation, plus contract-renewal.flow.ts:61-73 every day inside the notification window with no idempotency marker.
  • num_sent is written by both campaign-enrollment.flow.ts:55 and campaign.hook.ts:97; campaign-completion.flow.ts:46 triggers the latter.
  • Escalation fields are written by three different places with different field subsets: case-escalation.flow.ts:50, case-sla-monitor.flow.ts:55, case.actions.ts:25-32.
  • Quote totals: quote-generation.flow.ts:49-51 computes amount * (1 - discount/100); quote_line_item.hook.ts and all five seeded quotes compute subtotal − discount + tax + shipping. The flow (:63) also sets stage: 'proposal' unconditionally, which the opportunity_stage_progression state machine only allows from needs_analysis.
  • Stage→probability values are hardcoded outside the map in opportunity.hook.ts:27-35: opportunity.actions.ts:44, lead-conversion.flow.ts:126; the 14-day stagnation threshold is duplicated in opportunity.view.ts:189; thresholds 100000/500000 appear in 5 places.

Metadata

Metadata

Assignees

Labels

backendbugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions