Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@

- **Status:** Accepted
- **Revisions:** v1 2026-10-27 (initial); v2 2026-11-04 (a settled zoom is judged against the
zoom it last rested at)
- **Deciders:** Chirag Madlani
zoom it last rested at); v3 2026-11-12 (a zoom-out at the minimum zoom goes up a level)
- **Deciders:** Chirag Madlani; Mohit Yadav (v3)
- **Guard:** `LineageMap.utils.test.ts` (threshold either side of 35%, nearest-centre box,
drillable-with-children predicate); `PlatformLineage.spec.ts` (a fast zoom-in past the maximum
still drills); the settle delay and targeting are `reviewer`
still drills); `LineageMap.component.test.tsx` (wheel and button zoom-out at the minimum zoom);
the settle delay and targeting are `reviewer`
- **Related:** #36363, #36370

## Context
Expand All @@ -28,8 +29,11 @@ pause would drill when a pinch overshoots while the user only zooms in to read a
(`SEMANTIC_ZOOM_IN_SETTLE_MS`); any further move, a pan included, restarts that wait. When the
viewport settles, it is compared with the zoom it last rested at, not with the move before:
once the zoom reaches its maximum, the wheel keeps sending moves that no longer change the zoom.
- Zooming out is unchanged: it returns to the parent level as soon as the graph fills less than a
third of the canvas.
- Zooming out returns to the parent level as soon as the graph fills less than a third of the
canvas, or once the zoom reaches its minimum. At the minimum, d3-zoom drops a wheel gesture that
cannot change the zoom and the zoom-out button changes nothing, so no move arrives; a wheel-out or
zoom-out press there goes up a level directly. While a new scene settles and during the cooldown
it does nothing, so a zoom that reached the minimum then is not stuck there afterwards.

## Consequences
Drilling takes about half the wheel steps it did. A user zooming in only to read a card drills a
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -779,7 +779,15 @@ void testLineageMultipleColumnMappings() throws Exception {
}

@ParameterizedTest
@ValueSource(strings = {"{\"query\":", "{\"term\":{}}", "[\"not\",\"a\",\"query\"]"})
@ValueSource(
strings = {
"{\"query\":",
"{\"term\":{}}",
"[\"not\",\"a\",\"query\"]",
"[1]",
"{\"term\":{\"name\":{}}}",
"{\"terms\":{}}"
})
void testLineageSceneRejectsMalformedQueryFilter(String queryFilter) {
OpenMetadataClient client = SdkClients.adminClient();
RequestOptions options =
Expand All @@ -799,6 +807,9 @@ void testLineageSceneRejectsMalformedQueryFilter(String queryFilter) {

assertEquals(400, error.getStatusCode());
assertTrue(error.getMessage().startsWith("Invalid query_filter"), error.getMessage());
assertFalse(error.getMessage().contains("co.elastic"), error.getMessage());
assertFalse(error.getMessage().contains("org.opensearch"), error.getMessage());
assertFalse(error.getMessage().contains("Exception"), error.getMessage());
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
import org.openmetadata.schema.api.lineage.EsLineageData;
import org.openmetadata.schema.api.lineage.LineageBand;
import org.openmetadata.schema.api.lineage.LineageLens;
import org.openmetadata.schema.api.lineage.LineageLevelKind;
import org.openmetadata.schema.api.lineage.LineageSceneEdge;
import org.openmetadata.schema.api.lineage.LineageSceneNode;
import org.openmetadata.schema.api.lineage.SearchLineageResult;
Expand Down Expand Up @@ -167,7 +168,7 @@ private LineageSceneNode createNode(Ref ref, SceneAsset asset, boolean isGhost)
.withEntityType(ref.entityType())
.withLevelKind(ref.kind())
.withBand(nodeBand(ref.kind(), band))
.withServiceType(firstNonBlank(ref.serviceType(), asset.serviceType()))
.withServiceType(serviceType(ref, asset))
.withLabel(ref.label())
.withDisplayName(stringValue(ref.sourceEntity(), "displayName"))
.withParentId(parentId(ref, asset))
Expand All @@ -183,6 +184,14 @@ private LineageSceneNode createNode(Ref ref, SceneAsset asset, boolean isGhost)
.withSourceEntity(ref.sourceEntity());
}

// A domain or data product spans services, so the asset that drew its card says nothing
// about its type; without this the card reads, e.g., "CustomDatabase · data product".
private static String serviceType(Ref ref, SceneAsset asset) {
return ref.kind() == LineageLevelKind.DOMAIN || ref.kind() == LineageLevelKind.DATA_PRODUCT
? null
: firstNonBlank(ref.serviceType(), asset.serviceType());
}

private void mergeNodeCounts(LineageSceneNode node, Ref ref, SceneAsset asset) {
Set<String> countedAssetIds =
countedAssetIdsByNode.computeIfAbsent(node.getId(), ignored -> new LinkedHashSet<>());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@
import es.co.elastic.clients.elasticsearch._types.FieldValue;
import es.co.elastic.clients.elasticsearch._types.query_dsl.BoolQuery;
import es.co.elastic.clients.elasticsearch._types.query_dsl.Query;
import es.co.elastic.clients.json.JsonpMappingException;
import es.co.elastic.clients.json.jackson.JacksonJsonpMapper;
import es.co.elastic.clients.util.MissingRequiredPropertyException;
import jakarta.json.JsonException;
import jakarta.json.stream.JsonGenerator;
import jakarta.ws.rs.BadRequestException;
Expand All @@ -40,20 +42,49 @@ final class LineageSceneQuery {

private LineageSceneQuery() {}

// Reasons are worded for the caller: the search client's own messages name its classes.
static Query parseQueryFilter(String queryFilter) {
Query result = null;
if (!nullOrEmpty(queryFilter)) {
try {
JsonNode filter = JsonUtils.readTree(queryFilter);
JsonNode innerQuery = filter.has("query") ? filter.path("query") : filter;
if (!nullOrEmpty(innerQuery)) {
result = Query.of(clause -> clause.withJson(new StringReader(innerQuery.toString())));
}
} catch (JsonParsingException | JsonException e) {
throw new BadRequestException("Invalid query_filter: " + e.getMessage(), e);
}
if (nullOrEmpty(queryFilter)) {
return null;
}
JsonNode filter;
try {
filter = JsonUtils.readTree(queryFilter);
} catch (JsonParsingException e) {
throw invalidQueryFilter("it is not valid JSON", e);
}
JsonNode innerQuery = filter.has("query") ? filter.path("query") : filter;
if (nullOrEmpty(innerQuery)) {
return null;
}
if (!innerQuery.isObject()) {
throw invalidQueryFilter("a query must be a JSON object", null);
}
try {
return Query.of(clause -> clause.withJson(new StringReader(innerQuery.toString())));
} catch (JsonpMappingException e) {
throw invalidQueryFilter(mappingFailure(e), e);
} catch (MissingRequiredPropertyException e) {
throw invalidQueryFilter(missingProperty(e), e);
} catch (JsonException e) {
throw invalidQueryFilter("it is not a search query", e);
}
return result;
}

static BadRequestException invalidQueryFilter(String reason, Throwable cause) {
return new BadRequestException("Invalid query_filter: " + reason, cause);
}

private static String mappingFailure(JsonpMappingException e) {
String reason =
e.getCause() instanceof MissingRequiredPropertyException missing
? missingProperty(missing)
: "unexpected value";
return nullOrEmpty(e.path()) ? reason : reason + " at '" + e.path() + "'";
}

private static String missingProperty(MissingRequiredPropertyException e) {
return "missing required property '" + e.getPropertyName() + "'";
}

static String rootAssetQuery(LineageSceneRequest request) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import org.openmetadata.service.lineage.LineageSceneLoader.LoadedScene;
import org.openmetadata.service.lineage.LineageSceneMapper.Ref;
import org.openmetadata.service.lineage.LineageSceneMapper.SceneAsset;
import org.openmetadata.service.search.SearchEngineErrors;
import org.openmetadata.service.search.SearchRepository;
import org.openmetadata.service.search.lineage.LineageDomainFilter;
import org.openmetadata.service.security.policyevaluator.SubjectContext;
Expand Down Expand Up @@ -78,7 +79,16 @@ public LineageScene getScene(
includeDeleted,
securityContext,
subjectContext);
return getScene(request);
try {
return getScene(request);
} catch (IOException | RuntimeException e) {
// A filter can be a well-formed query that the engine still refuses, e.g. a term
// query whose value is an object; that is the caller's mistake, not a server fault.
if (request.queryFilter() != null && SearchEngineErrors.isRejectedRequest(e)) {
throw LineageSceneQuery.invalidQueryFilter("the search engine rejected it as a query", e);
}
throw e;
}
}

private LineageScene getScene(LineageSceneRequest request) throws IOException {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package org.openmetadata.service.search;

import es.co.elastic.clients.elasticsearch._types.ElasticsearchException;
import jakarta.ws.rs.core.Response;
import java.util.List;
import org.openmetadata.sdk.exception.SearchException;
import org.openmetadata.sdk.exception.SearchIndexNotFoundException;
import org.openmetadata.service.Entity;
import os.org.opensearch.client.opensearch._types.OpenSearchException;

/**
* Translates a search engine's own HTTP failure into the status OpenMetadata reports to its caller.
Expand Down Expand Up @@ -65,6 +67,33 @@ public static SearchException searchFailure(
statusFor(upstreamStatus), String.format("Search failed due to %s", detail));
}

/**
* Whether the search engine answered {@code 400} somewhere along {@code error}'s cause chain, for
* callers that reach the engine without going through a search manager's own translation.
*/
public static boolean isRejectedRequest(Throwable error) {
for (Throwable cause = error; cause != null; cause = nextCause(cause)) {
if (upstreamStatus(cause) == BAD_REQUEST) {
return true;
}
}
return false;
}

private static Throwable nextCause(Throwable error) {
return error.getCause() == error ? null : error.getCause();
}

private static int upstreamStatus(Throwable error) {
if (error instanceof ElasticsearchException elasticsearch) {
return elasticsearch.status();
}
if (error instanceof OpenSearchException openSearch) {
return openSearch.status();
}
return 0;
}

private static Response.Status statusFor(int upstreamStatus) {
return upstreamStatus == BAD_REQUEST
? Response.Status.BAD_REQUEST
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import java.util.Map;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.CsvSource;
import org.junit.jupiter.params.provider.NullAndEmptySource;
import org.junit.jupiter.params.provider.ValueSource;
import org.openmetadata.schema.utils.JsonUtils;
Expand Down Expand Up @@ -62,11 +63,41 @@ void normalizedFiltersPreserveInMemoryLineageMatches(String filter) {
}

@ParameterizedTest
@ValueSource(strings = {"{\"query\":", "{\"term\":{}}", "[\"not\",\"a\",\"query\"]"})
@ValueSource(
strings = {
"{\"query\":",
"{\"term\":{}}",
"[\"not\",\"a\",\"query\"]",
"[1]",
"\"tables\"",
"{\"terms\":{}}",
"{\"bool\":{\"must\":5}}",
"{\"range\":{\"x\":{\"boost\":\"high\"}}}"
})
void malformedFiltersAreRejectedAsBadRequests(String filter) {
BadRequestException error =
assertThrows(BadRequestException.class, () -> LineageSceneQuery.parseQueryFilter(filter));

assertTrue(error.getMessage().startsWith("Invalid query_filter"), error.getMessage());
assertTrue(error.getMessage().startsWith("Invalid query_filter: "), error.getMessage());
assertFalse(error.getMessage().contains("co.elastic"), error.getMessage());
assertFalse(error.getMessage().contains("Exception"), error.getMessage());
}

@ParameterizedTest
@CsvSource(
delimiter = '|',
value = {
"{\"query\":|it is not valid JSON",
"[1]|a query must be a JSON object",
"{\"query\":[1]}|a query must be a JSON object",
"{\"term\":{}}|unexpected value at 'term'",
"{\"bool\":{\"must\":5}}|unexpected value at 'bool.must'",
"{\"terms\":{}}|missing required property 'field' at 'terms'"
})
void malformedFiltersSayWhatIsWrongInTheCallersTerms(String filter, String reason) {
BadRequestException error =
assertThrows(BadRequestException.class, () -> LineageSceneQuery.parseQueryFilter(filter));

assertEquals("Invalid query_filter: " + reason, error.getMessage());
}
}
Loading
Loading