Add write operations for DataHub entities#41
Merged
Conversation
Seven tests covering all write methods (UpdateDescription, AddTag, RemoveTag, AddGlossaryTerm, RemoveGlossaryTerm, AddLink, RemoveLink) against a real DataHub instance. Gated by //go:build integration tag and run via make test-integration.
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #41 +/- ##
==========================================
+ Coverage 86.34% 87.75% +1.41%
==========================================
Files 32 37 +5
Lines 2299 2744 +445
==========================================
+ Hits 1985 2408 +423
+ Misses 215 207 -8
- Partials 99 129 +30 🚀 New features to boost your workflow:
|
Inline revive rules directly in .golangci.yml instead of using config-file reference, which is not supported in golangci-lint v2.1.6 (used by CI). Remove strict complexity rules (cognitive- complexity, cyclomatic, max-public-structs, argument-limit, function-result-limit) that were never enforced in CI.
Cover error paths in client write operations (invalid URN, server errors, invalid JSON responses) and REST API functions. Add write tool integration tests that invoke tools through the MCP server to cover register function closures.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds 7 write tools to the MCP DataHub toolkit, enabling AI assistants to modify DataHub metadata through the same composable interface used for reads. Write operations are disabled by default and must be explicitly opted in via
WriteEnabled: true.Write Tools Added
datahub_update_descriptiondatahub_add_tagdatahub_remove_tagdatahub_add_glossary_termdatahub_remove_glossary_termdatahub_add_linkdatahub_remove_linkArchitecture
Client Layer (
pkg/client/)rest.go— REST API infrastructure for DataHub's/aspectsendpoints. ImplementsgetAspect()for reading raw aspect JSON andpostIngestProposal()for writing metadata change proposals. All write operations use DataHub's REST API (not GraphQL) for better compatibility.write.go— Seven write methods on*Clientusing read-modify-write patterns:globalTagsaspect, adds/removes tag associations, writes backglossaryTermsaspect, adds/removes term associations, writes backinstitutionalMemoryaspect, adds/removes link elements, writes backeditableDatasetPropertiesaspect directlyTools Layer (
pkg/tools/)write_description.go,write_tags.go,write_glossary_terms.go,write_links.go— Tool handler implementations with input validation andWriteEnabledgating viagetWriteClient().Toolkit integration — Write tools are registered through the same
RegisterAll()/RegisterWith()pattern as read tools.getWriteClient()checksConfig.WriteEnabledbefore dispatching, returningErrWriteDisabledif writes are not opted in.Multi-server support — Per-connection
write_enabledoverrides viaConnectionConfig. A connection inherits the globalWriteEnabledsetting unless explicitly overridden.Configuration
Testing
Unit Tests (30 files changed, 3287 insertions)
rest_test.go— REST infrastructure tests:getAspect()success/not-found/unauthorized,postIngestProposal()success/error,checkRESTStatus()for all status codes,restBaseURL()derivation.write_test.go— All 7 write methods with httptest mocks covering: successful writes, duplicate detection (idempotency), missing aspects (404 → empty), invalid URNs.write_description_test.go,write_tags_test.go,write_glossary_terms_test.go,write_links_test.go— Tool handler tests covering: success paths, empty URN validation, write-disabled gating, client errors.toolkit_test.go— Extended with write tool registration coverage,WriteEnabledconfig tests, multi-server write override tests.Integration Tests (
write_integration_test.go)//go:build integrationt.Cleanup()registered before writes with independent contextsmake test-integrationwithDATAHUB_URLandDATAHUB_TOKENCoverage
golangci-lint(0 issues),go vet,gosec(0 issues),govulncheck(no vulnerabilities)Code Quality Improvements
.golangci.yml— Added additional linters and tighter thresholdsrevive.toml— Added revive linter configurationcodecov.yml— Added codecov configurationMakefile— Enhanced with coverage thresholds, mutation testing, patch coverage, security scanning, andverifytargetCLAUDE.md— Updated with write tools documentation and verification standardsTest Plan
make verifypasses (lint, test, coverage, security, deadcode, build)golangci-lint run— 0 issuesgosec ./...— 0 issuesgovulncheck ./...— no vulnerabilitiesgo test -race ./...— all pass (integration tests excluded by build tag)make test-integrationagainst a live DataHub instance