microg/GmsCore · error · IllegalStateException
Must set infectiousnessWhenDaysSinceOnsetMissing
Error message
Must set infectiousnessWhenDaysSinceOnsetMissing
What it means
DiagnosisKeysDataMapping.Builder.build() throws IllegalStateException when infectiousnessWhenDaysSinceOnsetMissing is null. This field tells the API which infectiousness level to assign to keys lacking day-since-onset data, so it must be explicitly provided.
Source
Thrown at play-services-nearby/src/main/java/com/google/android/gms/nearby/exposurenotification/DiagnosisKeysDataMapping.java:84
/**
* A builder for {@link DiagnosisKeysDataMapping}.
*/
public static class DiagnosisKeysDataMappingBuilder {
private final static int MAX_DAYS = 29;
private List<Integer> daysSinceOnsetToInfectiousness;
@ReportType
private int reportTypeWhenMissing = ReportType.UNKNOWN;
@Infectiousness
private Integer infectiousnessWhenDaysSinceOnsetMissing;
public DiagnosisKeysDataMapping build() {
if (daysSinceOnsetToInfectiousness == null)
throw new IllegalStateException("Must set daysSinceOnsetToInfectiousness");
if (reportTypeWhenMissing == ReportType.UNKNOWN)
throw new IllegalStateException("Must set reportTypeWhenMissing");
if (infectiousnessWhenDaysSinceOnsetMissing == null)
throw new IllegalStateException("Must set infectiousnessWhenDaysSinceOnsetMissing");
DiagnosisKeysDataMapping mapping = new DiagnosisKeysDataMapping();
mapping.daysSinceOnsetToInfectiousness = new ArrayList<>(daysSinceOnsetToInfectiousness);
mapping.reportTypeWhenMissing = reportTypeWhenMissing;
mapping.infectiousnessWhenDaysSinceOnsetMissing = infectiousnessWhenDaysSinceOnsetMissing;
return mapping;
}
public DiagnosisKeysDataMappingBuilder setDaysSinceOnsetToInfectiousness(Map<Integer, Integer> daysSinceOnsetToInfectiousness) {
if (daysSinceOnsetToInfectiousness.size() > MAX_DAYS)
throw new IllegalArgumentException("daysSinceOnsetToInfectiousness exceeds " + MAX_DAYS + " days");
Integer[] values = new Integer[MAX_DAYS];
Arrays.fill(values, 0);
for (Map.Entry<Integer, Integer> entry : daysSinceOnsetToInfectiousness.entrySet()) {
if (entry.getKey() > 14) throw new IllegalArgumentException("invalid day since onset");
values[entry.getKey() + 14] = entry.getValue();
}
this.daysSinceOnsetToInfectiousness = Arrays.asList(values);
return this;View on GitHub (pinned to 157c9d86ac)
Solutions
- Call setInfectiousnessWhenDaysSinceOnsetMissing(Infectiousness.STANDARD) (or another concrete level) before build()
- Audit the builder chain against the three required fields listed in build()
- Add a shared config helper that constructs the mapping completely
Example fix
// before
DiagnosisKeysDataMapping mapping = new DiagnosisKeysDataMapping.Builder()
.setDaysSinceOnsetToInfectiousness(days)
.setReportTypeWhenMissing(ReportType.CONFIRMED_TEST)
.build();
// after
DiagnosisKeysDataMapping mapping = new DiagnosisKeysDataMapping.Builder()
.setDaysSinceOnsetToInfectiousness(days)
.setReportTypeWhenMissing(ReportType.CONFIRMED_TEST)
.setInfectiousnessWhenDaysSinceOnsetMissing(Infectiousness.STANDARD)
.build(); Defensive patterns
Strategy: validation
Validate before calling
int infectiousnessWhenMissing = Infectiousness.STANDARD;
builder.setDaysSinceOnsetToInfectiousness(days)
.setReportTypeWhenMissing(ReportType.CONFIRMED_TEST)
.setInfectiousnessWhenDaysSinceOnsetMissing(infectiousnessWhenMissing)
.build(); Try / catch
try {
DiagnosisKeysDataMapping mapping = mappingBuilder.build();
} catch (IllegalStateException e) {
Log.w(TAG, "infectiousnessWhenDaysSinceOnsetMissing not set: " + e.getMessage());
} Prevention
- Treat the three builder fields as a required triple and set them together
- Use Infectiousness.STANDARD as a safe default fallback
- Add a startup assertion that builds the mapping successfully before exposure notifications are used
When it happens
Trigger: Calling build() without calling setInfectiousnessWhenDaysSinceOnsetMissing(@Infectiousness int).
Common situations: The map and report type fallback are configured but the infectiousness fallback is overlooked, often because it is the last of three required setters.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- Must set attenuationBucketThresholdDb
- Must set attenuationBucketWeights
- Must set daysSinceOnsetToInfectiousness
- Must set reportTypeWhenMissing
- daysSinceOnsetToInfectiousness exceeds MAX_DAYS days
AI-assisted analysis of microg/GmsCore@157c9d86ac (2026-09-06).
Data as JSON: /api/errors/628e2876123bd3a3.
Report an issue: GitHub.