microg/GmsCore · error · IllegalArgumentException
daysSinceOnsetToInfectiousness exceeds MAX_DAYS days
Error message
daysSinceOnsetToInfectiousness exceeds MAX_DAYS days
What it means
DiagnosisKeysDataMappingBuilder.setDaysSinceOnsetToInfectiousness throws IllegalArgumentException when the map contains more than MAX_DAYS entries. The API only supports a bounded window of days since symptom onset, so larger maps cannot be represented.
Source
Thrown at play-services-nearby/src/main/java/com/google/android/gms/nearby/exposurenotification/DiagnosisKeysDataMapping.java:94
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;
}
public DiagnosisKeysDataMappingBuilder setInfectiousnessWhenDaysSinceOnsetMissing(@Infectiousness int infectiousnessWhenDaysSinceOnsetMissing) {
this.infectiousnessWhenDaysSinceOnsetMissing = infectiousnessWhenDaysSinceOnsetMissing;
return this;
}
public DiagnosisKeysDataMappingBuilder setReportTypeWhenMissing(@ReportType int reportTypeWhenMissing) {
this.reportTypeWhenMissing = reportTypeWhenMissing;
return this;View on GitHub (pinned to 157c9d86ac)
Solutions
- Trim the map to at most MAX_DAYS entries (day offsets -14..14)
- Validate the map size before calling the setter and log/aggregate overflow entries
- If you need wider coverage, restrict to the onset window the Exposure Notification API supports
Example fix
// before
builder.setDaysSinceOnsetToInfectiousness(fullYearMap);
// after
Map<Integer, Integer> bounded = fullYearMap.entrySet().stream()
.filter(e -> e.getKey() >= -14 && e.getKey() <= 14)
.limit(29)
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
builder.setDaysSinceOnsetToInfectiousness(bounded); Defensive patterns
Strategy: validation
Validate before calling
if (daysMap.size() > 29) {
throw new IllegalArgumentException("map must have at most 29 day entries (-14..14)");
}
builder.setDaysSinceOnsetToInfectiousness(daysMap); Try / catch
try {
builder.setDaysSinceOnsetToInfectiousness(daysMap);
} catch (IllegalArgumentException e) {
Log.w(TAG, "Day map too large: " + e.getMessage());
} Prevention
- Only generate day keys within the -14..14 window (max 29 entries)
- Filter/aggregate input data to the supported window before calling the setter
- Add a bounds test to any code that programmatically builds the day map
When it happens
Trigger: Passing a Map<Integer,Integer> with more than MAX_DAYS distinct day-offset keys to setDaysSinceOnsetToInfectiousness.
Common situations: Apps build day maps covering a wider window than the 29-day supported range (e.g. generating entries for every possible day programmatically with the wrong bounds).
Understand the failure class
Background: "value must be between 0 and 1" / "out of range" / "must not be negative" errors: fixing range-validation failures across open-source libraries — this error's family across 42 libraries.
Related errors
- invalid day since onset
- Must set attenuationBucketThresholdDb
- Must set attenuationBucketWeights
- Must set daysSinceOnsetToInfectiousness
- Must set reportTypeWhenMissing
AI-assisted analysis of microg/GmsCore@157c9d86ac (2026-09-06).
Data as JSON: /api/errors/479b8b4cc056474c.
Report an issue: GitHub.