{"record":{"id":"0752f9ec44b516eb","repo":"microg/GmsCore","slug":"must-set-attenuationbucketweights","errorCode":null,"errorMessage":"Must set attenuationBucketWeights","messagePattern":"Must set attenuationBucketWeights","errorType":"validation","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"play-services-nearby/src/main/java/com/google/android/gms/nearby/exposurenotification/DailySummariesConfig.java","lineNumber":190,"sourceCode":"     */\n    public static class DailySummariesConfigBuilder {\n        private Double[] reportTypeWeights = new Double[ReportType.VALUES];\n        private Double[] infectiousnessWeights = new Double[Infectiousness.VALUES];\n        private List<Integer> attenuationBucketThresholdDb;\n        private List<Double> attenuationBucketWeights;\n        private int daysSinceExposureThreshold;\n        private double minimumWindowScore;\n\n        public DailySummariesConfigBuilder() {\n            Arrays.fill(reportTypeWeights, 0.0);\n            Arrays.fill(infectiousnessWeights, 0.0);\n        }\n\n        public DailySummariesConfig build() {\n            if (attenuationBucketThresholdDb == null)\n                throw new IllegalStateException(\"Must set attenuationBucketThresholdDb\");\n            if (attenuationBucketWeights == null)\n                throw new IllegalStateException(\"Must set attenuationBucketWeights\");\n            DailySummariesConfig config = new DailySummariesConfig();\n            config.reportTypeWeights = Arrays.asList(reportTypeWeights);\n            config.infectiousnessWeights = Arrays.asList(infectiousnessWeights);\n            config.attenuationBucketThresholdDb = attenuationBucketThresholdDb;\n            config.attenuationBucketWeights = attenuationBucketWeights;\n            config.daysSinceExposureThreshold = daysSinceExposureThreshold;\n            config.minimumWindowScore = minimumWindowScore;\n            return config;\n        }\n\n        /**\n         * See {@link #getAttenuationBucketThresholdDb()} and {@link #getAttenuationBucketWeights()}\n         */\n        public DailySummariesConfigBuilder setAttenuationBuckets(List<Integer> thresholds, List<Double> weights) {\n            attenuationBucketThresholdDb = new ArrayList<>(thresholds);\n            attenuationBucketWeights = new ArrayList<>(weights);\n            return this;\n        }","sourceCodeStart":172,"sourceCodeEnd":208,"githubUrl":"https://github.com/microg/GmsCore/blob/157c9d86ac46c195a86c2f15ab55c84036223f95/play-services-nearby/src/main/java/com/google/android/gms/nearby/exposurenotification/DailySummariesConfig.java#L172-L208","documentation":"DailySummariesConfig.Builder.build() throws IllegalStateException when attenuationBucketWeights was never set. The config needs one weight per attenuation bucket to score each exposure day; without it the summary would be meaningless, so the builder fails fast.","triggerScenarios":"Calling DailySummariesConfig.Builder.build() without calling setAttenuationBucketWeights(List<Double>) — only after the attenuationBucketThresholdDb check has already passed.","commonSituations":"Developers set thresholds but forget the matching weights list, or copy an example config that sets weights conditionally.","solutions":["Call builder.setAttenuationBucketWeights(...) with 4 weights (one per attenuation bucket) before build()","Verify the weights list size matches the number of buckets implied by the thresholds","Review the builder chain to ensure no required setter is skipped"],"exampleFix":"// before\nbuilder.setAttenuationBucketThresholdDb(Arrays.asList(30, 40, 60));\nDailySummariesConfig config = builder.build();\n// after\nbuilder.setAttenuationBucketThresholdDb(Arrays.asList(30, 40, 60));\nbuilder.setAttenuationBucketWeights(Arrays.asList(1.0, 1.0, 1.0, 1.0));\nDailySummariesConfig config = builder.build();","handlingStrategy":"validation","validationCode":"List<Double> weights = Arrays.asList(1.0, 1.0, 1.0, 1.0);\nif (weights == null || weights.size() != 4) {\n    throw new IllegalStateException(\"attenuationBucketWeights must be set (4 values)\");\n}\nDailySummariesConfig config = builder.setAttenuationBucketWeights(weights).build();","typeGuard":null,"tryCatchPattern":"try {\n    DailySummariesConfig config = builder.build();\n} catch (IllegalStateException e) {\n    Log.w(TAG, \"Incomplete DailySummariesConfig: \" + e.getMessage());\n}","preventionTips":["Set weights immediately after thresholds in the builder chain","Review the build() source for the complete list of required fields","Add a smoke test that builds the default app config at startup"],"tags":["java","builder-validation","exposure-notification"],"backgroundTag":"missing-required-argument","analyzedSha":"157c9d86ac46c195a86c2f15ab55c84036223f95","analyzedAt":"2026-09-06T17:27:33.892Z","contentChangedAt":"2026-09-06T17:27:33.892Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}