{"record":{"id":"479b8b4cc056474c","repo":"microg/GmsCore","slug":"dayssinceonsettoinfectiousness-exceeds-max-days-da","errorCode":null,"errorMessage":"daysSinceOnsetToInfectiousness exceeds MAX_DAYS days","messagePattern":"daysSinceOnsetToInfectiousness exceeds MAX_DAYS days","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"play-services-nearby/src/main/java/com/google/android/gms/nearby/exposurenotification/DiagnosisKeysDataMapping.java","lineNumber":94,"sourceCode":"        private Integer infectiousnessWhenDaysSinceOnsetMissing;\n\n        public DiagnosisKeysDataMapping build() {\n            if (daysSinceOnsetToInfectiousness == null)\n                throw new IllegalStateException(\"Must set daysSinceOnsetToInfectiousness\");\n            if (reportTypeWhenMissing == ReportType.UNKNOWN)\n                throw new IllegalStateException(\"Must set reportTypeWhenMissing\");\n            if (infectiousnessWhenDaysSinceOnsetMissing == null)\n                throw new IllegalStateException(\"Must set infectiousnessWhenDaysSinceOnsetMissing\");\n            DiagnosisKeysDataMapping mapping = new DiagnosisKeysDataMapping();\n            mapping.daysSinceOnsetToInfectiousness = new ArrayList<>(daysSinceOnsetToInfectiousness);\n            mapping.reportTypeWhenMissing = reportTypeWhenMissing;\n            mapping.infectiousnessWhenDaysSinceOnsetMissing = infectiousnessWhenDaysSinceOnsetMissing;\n            return mapping;\n        }\n\n        public DiagnosisKeysDataMappingBuilder setDaysSinceOnsetToInfectiousness(Map<Integer, Integer> daysSinceOnsetToInfectiousness) {\n            if (daysSinceOnsetToInfectiousness.size() > MAX_DAYS)\n                throw new IllegalArgumentException(\"daysSinceOnsetToInfectiousness exceeds \" + MAX_DAYS + \" days\");\n            Integer[] values = new Integer[MAX_DAYS];\n            Arrays.fill(values, 0);\n            for (Map.Entry<Integer, Integer> entry : daysSinceOnsetToInfectiousness.entrySet()) {\n                if (entry.getKey() > 14) throw new IllegalArgumentException(\"invalid day since onset\");\n                values[entry.getKey() + 14] = entry.getValue();\n            }\n            this.daysSinceOnsetToInfectiousness = Arrays.asList(values);\n            return this;\n        }\n\n        public DiagnosisKeysDataMappingBuilder setInfectiousnessWhenDaysSinceOnsetMissing(@Infectiousness int infectiousnessWhenDaysSinceOnsetMissing) {\n            this.infectiousnessWhenDaysSinceOnsetMissing = infectiousnessWhenDaysSinceOnsetMissing;\n            return this;\n        }\n\n        public DiagnosisKeysDataMappingBuilder setReportTypeWhenMissing(@ReportType int reportTypeWhenMissing) {\n            this.reportTypeWhenMissing = reportTypeWhenMissing;\n            return this;","sourceCodeStart":76,"sourceCodeEnd":112,"githubUrl":"https://github.com/microg/GmsCore/blob/157c9d86ac46c195a86c2f15ab55c84036223f95/play-services-nearby/src/main/java/com/google/android/gms/nearby/exposurenotification/DiagnosisKeysDataMapping.java#L76-L112","documentation":"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.","triggerScenarios":"Passing a Map<Integer,Integer> with more than MAX_DAYS distinct day-offset keys to setDaysSinceOnsetToInfectiousness.","commonSituations":"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).","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"],"exampleFix":"// before\nbuilder.setDaysSinceOnsetToInfectiousness(fullYearMap);\n// after\nMap<Integer, Integer> bounded = fullYearMap.entrySet().stream()\n    .filter(e -> e.getKey() >= -14 && e.getKey() <= 14)\n    .limit(29)\n    .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));\nbuilder.setDaysSinceOnsetToInfectiousness(bounded);","handlingStrategy":"validation","validationCode":"if (daysMap.size() > 29) {\n    throw new IllegalArgumentException(\"map must have at most 29 day entries (-14..14)\");\n}\nbuilder.setDaysSinceOnsetToInfectiousness(daysMap);","typeGuard":null,"tryCatchPattern":"try {\n    builder.setDaysSinceOnsetToInfectiousness(daysMap);\n} catch (IllegalArgumentException e) {\n    Log.w(TAG, \"Day map too large: \" + e.getMessage());\n}","preventionTips":["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"],"tags":["java","argument-validation","exposure-notification"],"backgroundTag":"value-out-of-range","analyzedSha":"157c9d86ac46c195a86c2f15ab55c84036223f95","analyzedAt":"2026-09-06T17:27:33.892Z","contentChangedAt":"2026-09-06T17:27:33.892Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}