Skip to content
Ritesh FirodiyaGet in touch

Work / Chitragupt / Wiki / Decisions

2026-07-05-rename-on-consult-request-paid-trigger

Decisionsupersededverified 2026-07-05

DECISION.2026-07-05.RENAME-ON-CONSULT-REQUEST-PAID-TRIGGER

Rename onConsultRequestPaid → onConsultRequestPaidWritten

Decision

Rename the Firestore trigger that mints an engagement when a consult request flips to paid_pending_assignment. Old export: onConsultRequestPaid (file on-consult-request-paid.ts). New export: onConsultRequestPaidWritten (file on-consult-request-paid-written.ts).

Why

Prod already held an HTTPS callable under the name onConsultRequestPaid — a leftover from the first rename attempt (see 2026-07-02-rename-on-consult-paid-trigger) whose deploy landed the function as HTTPS before the trigger conversion completed. CI has been red on main with:

[onConsultRequestPaid(asia-south1)] Changing from an HTTPS function to a background triggered function is not allowed.

Firebase does not allow swapping a function's trigger type in place. Renaming makes Firebase treat it as a new deployment; the orphan HTTPS onConsultRequestPaid is cleaned up by the existing --force flag on firebase deploy.

The new name also aligns with the on<X>Written pattern used by the other onDocumentWritten triggers in apps/functions/src/triggers/firestore/ — onLedgerEntryWritten, onAnalyzeOutputWritten, onCaRatingWritten, onQuickCheckAnswerWritten.

Impact

  • apps/functions/src/triggers/firestore/on-consult-request-paid.ts → renamed to on-consult-request-paid-written.ts; export renamed accordingly.
  • apps/functions/src/index.ts re-export updated.
  • packages/shared/src/schemas/consult-request.ts doc comment updated.
  • No callable-contract or Firestore-schema change — the trigger listens to the same users/{uid}/consult_requests/{consultId} path.
  • Affects the pillar-marketplace Get-a-CA flow. Idempotency is preserved (still keyed on consult_${consultId}).

Status

Active.

Sources

  • CI failure on Firebase deploy step — same trigger-type-change error as 2026-07-02-rename-on-consult-paid-trigger.
  • apps/functions/src/triggers/firestore/on-consult-request-paid-written.ts — trigger implementation.

Every project of mine is written down like this.

Read the résumé