[fault injection] add defensive check against can't happen condition (#37743)

Fixes #37698.

Closes #37743

COPYBARA_INTEGRATE_REVIEW=https://github.com/grpc/grpc/pull/37743 from markdroth:fault_injection_defensive 1684f05911
PiperOrigin-RevId: 677854945
pull/37646/head
Mark D. Roth 4 months ago committed by Copybara-Service
parent b87ed725df
commit c7cc8c1eac
  1. 6
      src/core/ext/filters/fault_injection/fault_injection_filter.cc

@ -174,6 +174,12 @@ FaultInjectionFilter::MakeInjectionDecision(
fi_policy = method_params->fault_injection_policy(index_);
}
// Shouldn't ever be null, but just in case, return a no-op decision.
if (fi_policy == nullptr) {
return InjectionDecision(/*max_faults=*/0, /*delay_time=*/Duration::Zero(),
/*abort_request=*/absl::nullopt);
}
grpc_status_code abort_code = fi_policy->abort_code;
uint32_t abort_percentage_numerator = fi_policy->abort_percentage_numerator;
uint32_t delay_percentage_numerator = fi_policy->delay_percentage_numerator;

Loading…
Cancel
Save