Skip to content

Commit

Permalink
Fixed RD-15230: 'summary' and 'description' returned as NULL (#13)
Browse files Browse the repository at this point in the history
The 'summary' and 'description' fields were being retrieved using
incorrect keys, bypassing the necessary indirection through names. For
instance, instead of using `f.get(names.get("Description"))`, and
therefore extract the `"description"` key (lowercase `d`), the code
directly called `f.get("Description")`. Field `components` had a similar problem.

Additionally, the `description` field has been updated to be an `any`,
as real-world data indicates it can be a JSON object.
  • Loading branch information
bgaidioz authored Dec 13, 2024
1 parent 4e8968f commit 5b5eced
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,13 @@ protected void processFields(
creator.map(c -> c.get("displayName")).orElse(null),
columns);

addToRow(
"description",
rowBuilder,
maybeFields.map(f -> f.get("Description")).orElse(null),
columns);
var description = maybeFields.map(f -> f.get(names.get("Description"))).orElse(null);
try {
// 'description' is an object, so we need to serialize it. It's then sent as 'any'.
addToRow("description", rowBuilder, objectMapper.writeValueAsString(description), columns);
} catch (JsonProcessingException e) {
throw new DASSdkApiException("error processing 'description'", e);
}

addToRow(
"due_date",
Expand All @@ -110,7 +112,11 @@ protected void processFields(
reporter.map(r -> r.get("displayName")).orElse(null),
columns);

addToRow("summary", rowBuilder, maybeFields.map(f -> f.get("Summary")).orElse(null), columns);
addToRow(
"summary",
rowBuilder,
maybeFields.map(f -> f.get(names.get("Summary"))).orElse(null),
columns);

var type =
maybeFields
Expand All @@ -128,7 +134,7 @@ protected void processFields(

var componentIds =
maybeFields
.map(f -> ((ArrayList<Object>) f.get("Components")))
.map(f -> ((ArrayList<Object>) f.get(names.get("Components"))))
.map(
c -> {
List<String> cmpIds = new ArrayList<>();
Expand All @@ -151,6 +157,9 @@ protected void processFields(
maybeFields.map(f -> f.get(names.get("Labels"))).orElse(null),
columns);

// 'tags' is a map of labels, all mapped to boolean true. It is in the steampipe schema. We
// advertise a
// similar field in the DAS schema.
Map<String, Boolean> tags =
maybeFields
.map(f -> (List<String>) f.get(names.get("Labels")))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,8 +218,7 @@ protected LinkedHashMap<String, ColumnDefinition> buildColumnDefinitions() {
"Display name of the user/application that created the issue.",
createStringType()));
columnDefinitions.put(
"description",
createColumn("description", "Description of the issue.", createStringType()));
"description", createColumn("description", "Description of the issue.", createAnyType()));
columnDefinitions.put(
"due_date",
createColumn(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ protected LinkedHashMap<String, ColumnDefinition> buildColumnDefinitions() {
"Time by which the issue is expected to be completed",
createTimestampType()));
columns.put(
"description", createColumn("description", "Description of the issue", createStringType()));
"description", createColumn("description", "Description of the issue", createAnyType()));
columns.put("type", createColumn("type", "The name of the issue type", createStringType()));
columns.put(
"labels",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.rawlabs.das.jira.tables.defnitions;

import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.rawlabs.das.jira.rest.platform.ApiException;
import com.rawlabs.das.jira.rest.platform.api.IssueSearchApi;
import com.rawlabs.das.jira.rest.platform.model.SearchResults;
Expand All @@ -13,6 +14,7 @@
import org.mockito.Mock;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import static org.junit.jupiter.api.Assertions.*;
Expand Down Expand Up @@ -59,6 +61,14 @@ void testGetIssues() throws IOException {
assertEquals("33060", extractValueFactory.extractValue(row, "id"));
assertEquals("SP-1", extractValueFactory.extractValue(row, "key"));
assertEquals("Task", extractValueFactory.extractValue(row, "type"));
assertEquals("test issue", extractValueFactory.extractValue(row, "summary"));
ObjectNode description = (ObjectNode) extractValueFactory.extractValue(row, "description");
// Fetch the first text of the content ("do this")
assertEquals(
"do this", description.get("content").get(0).get("content").get(0).get("text").asText());
ArrayList<String> components =
(ArrayList<String>) extractValueFactory.extractValue(row, "components");
assertEquals("10151", components.get(0));
assertFalse(result.hasNext());
}
}
Expand Down
4 changes: 2 additions & 2 deletions das-jira-connector/src/test/resources/mock-data/issues.json
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,9 @@
"name": "To Do"
}
},
"components": [],
"components": [{"self":"https://raw-labs.atlassian.net/rest/api/3/component/10151", "id":"10151", "name":"aComponent"}],
"timeoriginalestimate": null,
"description": null,
"description": {"type":"doc","version":1.0,"content":[{"type":"paragraph","content":[{"type":"text","text":"do this"}]}]},
"customfield_10653": null,
"customfield_10600": null,
"security": null,
Expand Down

0 comments on commit 5b5eced

Please sign in to comment.