microg/GmsCore · error · IllegalStateException
Must set reportTypeWhenMissing
Error message
Must set reportTypeWhenMissing
What it means
DiagnosisKeysDataMapping.Builder.build() throws IllegalStateException when reportTypeWhenMissing is still ReportType.UNKNOWN (its default). The API needs to know which report type to assume when a key has no report type; UNKNOWN is treated as 'not configured'.
Source
Thrown at play-services-nearby/src/main/java/com/google/android/gms/nearby/exposurenotification/DiagnosisKeysDataMapping.java:82
return reportTypeWhenMissing;
}
/**
* 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();
}View on GitHub (pinned to 157c9d86ac)
Solutions
- Call setReportTypeWhenMissing with a concrete type such as ReportType.CONFIRMED_TEST or ReportType.CONFIRMED_CLINICAL_DIAGNOSIS
- Do not pass ReportType.UNKNOWN; it is only the sentinel default
- Set all three required fields (map, reportTypeWhenMissing, infectiousnessWhenDaysSinceOnsetMissing) together
Example fix
// before builder.setReportTypeWhenMissing(ReportType.UNKNOWN); // after builder.setReportTypeWhenMissing(ReportType.CONFIRMED_TEST);
Defensive patterns
Strategy: validation
Validate before calling
if (reportTypeWhenMissing == ReportType.UNKNOWN) {
reportTypeWhenMissing = ReportType.CONFIRMED_TEST; // sensible default
}
builder.setReportTypeWhenMissing(reportTypeWhenMissing); Try / catch
try {
DiagnosisKeysDataMapping mapping = mappingBuilder.build();
} catch (IllegalStateException e) {
Log.w(TAG, "reportTypeWhenMissing not configured: " + e.getMessage());
} Prevention
- Never pass ReportType.UNKNOWN as the fallback value
- Choose the fallback report type as a product decision, not a default constant
- Log the configured mapping at startup to catch misconfiguration early
When it happens
Trigger: Calling build() without calling setReportTypeWhenMissing(@ReportType int) — or explicitly passing ReportType.UNKNOWN.
Common situations: Developers set the infectiousness fallback but forget the report-type fallback, or mistakenly pass ReportType.UNKNOWN thinking it means 'any'.
Understand the failure class
Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.
Related errors
- Must set attenuationBucketThresholdDb
- Must set attenuationBucketWeights
- Must set daysSinceOnsetToInfectiousness
- Must set infectiousnessWhenDaysSinceOnsetMissing
- daysSinceOnsetToInfectiousness exceeds MAX_DAYS days
AI-assisted analysis of microg/GmsCore@157c9d86ac (2026-09-06).
Data as JSON: /api/errors/75a89c5be2576518.
Report an issue: GitHub.