From f6fa6da45c8c51fbff2fb9c90048934cad84a451 Mon Sep 17 00:00:00 2001
From: Simone Basso <bassosimone@gmail.com>
Date: Tue, 12 Nov 2019 16:23:41 +0100
Subject: [PATCH] collector: unconditionally write the ReportID (#104)

* collector: unconditionally write the ReportID

Issue reported by @FedericoCeratto

* Update mkevent.go
---
 collector/collector.go        | 8 ++++----
 experiment/mkevent/mkevent.go | 2 +-
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/collector/collector.go b/collector/collector.go
index d82af488..21e52359 100644
--- a/collector/collector.go
+++ b/collector/collector.go
@@ -124,13 +124,14 @@ type updateResponse struct {
 }
 
 // SubmitMeasurement submits a measurement belonging to the report
-// to the OONI collector. On success, we will modify the measurement
-// updating its ReportID field. If the collector supports sending back to
-// us a measurement ID, we also update the m.OOID field with it.
+// to the OONI collector. We will unconditionally modify the measurement
+// with the ReportID it should contain. If the collector supports sending
+// back to us a measurement ID, we also update the m.OOID field with it.
 func (r *Report) SubmitMeasurement(
 	ctx context.Context, m *model.Measurement,
 ) error {
 	var updateResponse updateResponse
+	m.ReportID = r.ID
 	err := (&jsonapi.Client{
 		BaseURL:    r.client.BaseURL,
 		HTTPClient: r.client.HTTPClient,
@@ -143,7 +144,6 @@ func (r *Report) SubmitMeasurement(
 		}, &updateResponse,
 	)
 	if err == nil {
-		m.ReportID = r.ID
 		m.OOID = updateResponse.ID
 	}
 	return err
diff --git a/experiment/mkevent/mkevent.go b/experiment/mkevent/mkevent.go
index 1709edc1..4151522b 100644
--- a/experiment/mkevent/mkevent.go
+++ b/experiment/mkevent/mkevent.go
@@ -20,7 +20,7 @@ func Handle(
 ) {
 	if event.Key == "measurement" {
 		// We reparse the measurement and overwrite it. This is how we manage to
-		// return the measurement to the caller. Seriousy.
+		// return the measurement to the caller. Seriously.
 		//
 		// We panic if we cannot parse because since MK v0.9.0 the vendored
 		// nlohmann/json library should throw if passed non UTF-8 input.
-- 
GitLab