{"record":{"id":"9903587b8c2fe6e5","repo":"microg/GmsCore","slug":"conflicting-data-sources-found","errorCode":null,"errorMessage":"Conflicting data sources found","messagePattern":"Conflicting data sources found","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"play-services-fitness/src/main/java/com/google/android/gms/fitness/data/DataSet.java","lineNumber":68,"sourceCode":"    DataSet(@NonNull DataSource dataSource) {\n        this.versionCode = 3;\n        this.dataSource = dataSource;\n        this.rawDataPoints = new ArrayList<>();\n        this.uniqueDataSources = new ArrayList<>();\n        uniqueDataSources.add(dataSource);\n    }\n\n    /**\n     * Adds a data point to this data set. The data points should be for the correct data type and data source, and should have its timestamp\n     * already set.\n     *\n     * @throws IllegalArgumentException If dataPoint has invalid data.\n     * @deprecated Build {@link DataSet} instances using the builder.\n     */\n    @Deprecated\n    public void add(@NonNull DataPoint dataPoint) {\n        if (!dataPoint.getDataSource().getStreamIdentifier().equals(dataSource.getStreamIdentifier()))\n            throw new IllegalArgumentException(\"Conflicting data sources found\");\n        // TODO\n        rawDataPoints.add(dataPoint);\n    }\n\n    /**\n     * Adds a list of data points to this data set in bulk. All data points should be for the correct data type and data source, and should have their\n     * timestamp already set.\n     *\n     * @deprecated Build {@link DataSet} instances using the builder.\n     */\n    @Deprecated\n    public void addAll(@NonNull Iterable<DataPoint> iterable) {\n        for (DataPoint dataPoint : iterable) {\n            add(dataPoint);\n        }\n    }\n\n    /**","sourceCodeStart":50,"sourceCodeEnd":86,"githubUrl":"https://github.com/microg/GmsCore/blob/157c9d86ac46c195a86c2f15ab55c84036223f95/play-services-fitness/src/main/java/com/google/android/gms/fitness/data/DataSet.java#L50-L86","documentation":"Thrown by the deprecated DataSet.add(DataPoint) when the DataPoint's DataSource stream identifier does not match the DataSet's DataSource stream identifier. A DataSet can only contain points produced by a single data source, so a mismatched point is rejected to keep the data set consistent.","triggerScenarios":"Calling DataSet.add(dataPoint) (the deprecated raw method) where dataPoint.getDataSource().getStreamIdentifier() differs from the stream identifier of the DataSet's own dataSource — typically when mixing points built from different DataSource builders.","commonSituations":"Building one shared DataSource for a data type but accidentally creating per-point DataSources with different stream names; copying DataPoints between DataSets created from different sources; legacy code paths that bypass DataSet.Builder.","solutions":["Use DataSet.Builder (DataSet.builder(dataSource)) and add points via Builder.add so the source is enforced consistently.","Ensure every DataPoint is created from exactly the same DataSource instance (or one with an identical stream identifier) as the DataSet.","Give every DataSource used for the same stream the same streamName/streamIdentifier via setStreamName.","Migrate away from the deprecated add() to the builder API, which validates against the correct source."],"exampleFix":"// before\nDataSet ds = new DataSet(dataType);\nds.add(pointFromOtherSource); // throws\n// after\nDataSet ds = DataSet.builder(sharedDataSource).add(pointFromSharedSource).build();","handlingStrategy":"validation","validationCode":"if (!dataPoint.getDataSource().getStreamIdentifier().equals(dataSetDataSource.getStreamIdentifier())) throw new IllegalArgumentException(\"point source mismatch\");","typeGuard":"boolean matchesSource(DataPoint p, DataSource ds) { return p.getDataSource().getStreamIdentifier().equals(ds.getStreamIdentifier()); }","tryCatchPattern":"try { dataSet.add(dataPoint); } catch (IllegalArgumentException e) { log.warn(\"Skipping point from wrong source\", e); }","preventionTips":["Use DataSet.Builder exclusively instead of the deprecated DataSet.add().","Share one DataSource instance across the DataSet and all its DataPoints.","Always set the same streamName for sources representing the same stream.","Verify stream identifiers when copying points between DataSets."],"tags":["android","google-fit","data-source-mismatch","deprecated-api"],"backgroundTag":"incompatible-source-type","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"}