Change Data Capture event object keeps the __c suffix
ID |
apex.correctness.change_data_capture_naming |
Severity |
high |
Remediation Complexity |
trivial |
Remediation Risk |
low |
Remediation Effort |
low |
Resource |
Api Usage |
Language |
Apex |
Description
Reports a Change Data Capture event object name built by appending to the custom object’s c suffix - InvoicecChangeEvent or InvoicecChangeEvent - instead of replacing it with __ChangeEvent.
Rationale
The event object for a custom object replaces the c suffix rather than extending it: Invoicec publishes to InvoiceChangeEvent. A name that keeps the c does not resolve, so the trigger never fires and the subscription never receives anything - and because there is no such object, nothing raises an error where the name is written as a string channel: the subscriber simply sits there receiving no events, which reads as "no changes happened" rather than as a defect.
The following code illustrates the pattern detected by this rule:
public class ChangeFeed {
public List<SObject> invoiceChanges() {
// FLAGGED: Change Data Capture event object keeps the __c suffix
return [SELECT ReplayId FROM Invoice__c__ChangeEvent];
}
public String badChannel() {
// FLAGGED: Change Data Capture event object keeps the __c suffix
return '/data/Invoice__cChangeEvent';
}
public List<SObject> invoiceChangesCorrect() {
return [SELECT ReplayId FROM Invoice__ChangeEvent];
}
public List<SObject> accountChanges() {
return [SELECT ReplayId FROM AccountChangeEvent];
}
public String channel() {
return '/data/Invoice__ChangeEvent';
}
}