diff --git a/src/main/java/io/cryostat/net/web/http/api/v2/graph/StartRecordingOnTargetMutator.java b/src/main/java/io/cryostat/net/web/http/api/v2/graph/StartRecordingOnTargetMutator.java index 83b5e5aec8..edf17e49de 100644 --- a/src/main/java/io/cryostat/net/web/http/api/v2/graph/StartRecordingOnTargetMutator.java +++ b/src/main/java/io/cryostat/net/web/http/api/v2/graph/StartRecordingOnTargetMutator.java @@ -38,6 +38,8 @@ package io.cryostat.net.web.http.api.v2.graph; import java.util.EnumSet; +import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Set; import java.util.concurrent.TimeUnit; @@ -57,6 +59,7 @@ import io.cryostat.net.TargetConnectionManager; import io.cryostat.net.security.ResourceAction; import io.cryostat.net.web.WebServer; +import io.cryostat.net.web.http.api.v2.graph.PutActiveRecordingMetadataMutator.InputRecordingLabel; import io.cryostat.platform.ServiceRef; import io.cryostat.platform.discovery.TargetNode; import io.cryostat.recordings.RecordingMetadataManager; @@ -161,11 +164,21 @@ public HyperlinkedSerializableRecordingDescriptor getAuthenticated( } Metadata m = new Metadata(); if (settings.containsKey("metadata")) { - m = - (Metadata) - gson.fromJson( - settings.get("metadata").toString(), - new TypeToken() {}.getType()); + Map _metadata = + gson.fromJson( + settings.get("metadata").toString(), + new TypeToken>() {}.getType()); + + Map labels = new HashMap<>(); + List inputLabels = + gson.fromJson( + _metadata.get("labels").toString(), + new TypeToken>() {}.getType()); + + for (InputRecordingLabel l : inputLabels) { + labels.put(l.getKey(), l.getValue()); + } + m = new Metadata(labels); } IRecordingDescriptor desc = recordingTargetHelper.startRecording( diff --git a/src/test/java/itest/GraphQLIT.java b/src/test/java/itest/GraphQLIT.java index badf8684db..fafde36a5b 100644 --- a/src/test/java/itest/GraphQLIT.java +++ b/src/test/java/itest/GraphQLIT.java @@ -278,10 +278,10 @@ void testStartRecordingMutationOnSpecificTarget() throws Exception { query.put( "query", "query { targetNodes(filter: { annotations: \"PORT == 9093\" }) {" - + " doStartRecording(recording: { name: \"graphql-itest\", duration: 30," - + " template: \"Profiling\", templateType: \"TARGET\", archiveOnStop: true," - + " metadata: { labels: { newLabel: someValue } } }) { name state duration" - + " archiveOnStop }} }"); + + " doStartRecording(recording: { name: \"graphql-itest\", duration: 30," + + " template: \"Profiling\", templateType: \"TARGET\", archiveOnStop: true," + + " metadata: { labels: [ { key: \"newLabel\", value: \"someValue\"} ] } }) {" + + " name state duration archiveOnStop }} }"); Map expectedLabels = Map.of( "template.name",