Repository navigation
Fixes #32600: include samples in AI context - #32608
Conversation
Limit structured table context to 10 permission-filtered rows so SQL agents can inspect value shape without a warehouse discovery query.
✅ Playwright Results — workflow succeededValidated commit ✅ 764 passed · ❌ 0 failed · 🟡 1 flaky · ⏭️ 0 skipped · 🧰 0 lifecycle flaky PerformanceBlocking targets: ✅ met · Optimization targets: 🟡 in progress Shard-job maxima below are not the full workflow wall time; the linked run includes build, fixture, planning, and reporting. 🕒 Full workflow signal wall (to summary) 48m 31s ⏱️ Max setup 4m 53s · max shard execution 15m 16s · max shard-job elapsed before upload 19m 28s · reporting 5s 🌐 236.82 requests/attempt · 2.51 app boots/UI scenario · 25.44% common-shard skew Optimization targets still in progress:
🟡 1 flaky test(s) (passed on retry)
How to debug locally# Download playwright-test-results-<shard> artifact and unzip
npx playwright show-trace path/to/trace.zip # view trace |
The AI context sample-data check wrapped an already-loaded table in a
pre-resolved ResourceContext. That constructor never runs resolveEntity(),
so owners and domains stayed absent (TABLE_FIELDS does not request them)
and every owner- or domain-conditioned rule misfired in both directions:
an owner-conditioned Deny failed open, and authorizePII() saw null owners
so a table's own owner had their sample data masked.
Resolve by id instead, which loads authorizationFields(), matching what
TableResource's GET /tables/{id}/sampleData already does.
The existing IT used an unconditioned Deny, which passes whether or not
owners are loaded. Add an owner-conditioned Deny case that first asserts
the real endpoint returns 403, then asserts the AI context endpoint
agrees. Verified: it returns 10 sample rows before the fix, none after.
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Code Review ✅ Approved 1 resolved / 1 findingsAdds table samples to the AI context endpoint so SQL agents can inspect representative data shapes without querying the warehouse. The stored samples are limited to 10 rows, reuse existing ✅ 1 resolved✅ Security: Sample-data authz uses table loaded without owners/domains
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 |
|
|
* feat(api): add samples to AI context
Limit structured table context to 10 permission-filtered rows so SQL agents can inspect value shape without a warehouse discovery query.
* fix(api): resolve sample-data authz with owners loaded
The AI context sample-data check wrapped an already-loaded table in a
pre-resolved ResourceContext. That constructor never runs resolveEntity(),
so owners and domains stayed absent (TABLE_FIELDS does not request them)
and every owner- or domain-conditioned rule misfired in both directions:
an owner-conditioned Deny failed open, and authorizePII() saw null owners
so a table's own owner had their sample data masked.
Resolve by id instead, which loads authorizationFields(), matching what
TableResource's GET /tables/{id}/sampleData already does.
The existing IT used an unconditioned Deny, which passes whether or not
owners are loaded. Add an owner-conditioned Deny case that first asserts
the real endpoint returns 403, then asserts the AI context endpoint
agrees. Verified: it returns 10 sample rows before the fix, none after.
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
---------
Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
(cherry picked from commit 8298911)
* feat(data-insights): capture completeness evidence and extend run lifecycle * feat(search): report embedding token usage instead of discarding it (#32552) * feat(search): report embedding token usage instead of discarding it * fix(search): report the text the provider received, not the caller's input (cherry picked from commit 2209bd7) * Restrict cross-user follower changes (#32322) * fix(security): restrict cross-user follower changes * fix(security): validate follower user IDs * fix(cache): bypass read-bundle cache for uncached entities buildReadBundle used the read-bundle cache for every non-deleted read, ignoring UNCACHED_ENTITY_TYPES (user, task, workflow*, bot, domain, dataProduct). For those types a mutation followed by an immediate re-read — e.g. the follower add/delete then fetch in this PR's DataProductResourceIT — could serve a stale cached bundle. Without this, the follower authorization tests fail under a cache-enabled deployment (postgres-elasticsearch-redis / postgres-opensearch integration lanes) with `expected <false> but was <true>` after a delete. Gate the read-bundle cache on isCacheableEntityType(entityType) so uncached types take the already-supported bundleCache == null path and always reflect the current entity_relationship state. Required for the follower tests to pass on the Redis/OpenSearch lanes (documents why this caching change is part of the security fix, per reviewer request). * test(followers): rename put_-prefixed delete-follower tests to delete_ prefix The two round-trip tests exercise the DELETE follower endpoint (add is setup), so name them with the delete_ verb prefix to match the method-name convention (addresses the Copilot review comment). --------- Co-authored-by: sonika-shah <[email protected]> (cherry picked from commit 2fb1cb5) * Fixes #32600: include samples in AI context (#32608) * feat(api): add samples to AI context Limit structured table context to 10 permission-filtered rows so SQL agents can inspect value shape without a warehouse discovery query. * fix(api): resolve sample-data authz with owners loaded The AI context sample-data check wrapped an already-loaded table in a pre-resolved ResourceContext. That constructor never runs resolveEntity(), so owners and domains stayed absent (TABLE_FIELDS does not request them) and every owner- or domain-conditioned rule misfired in both directions: an owner-conditioned Deny failed open, and authorizePII() saw null owners so a table's own owner had their sample data masked. Resolve by id instead, which loads authorizationFields(), matching what TableResource's GET /tables/{id}/sampleData already does. The existing IT used an unconditioned Deny, which passes whether or not owners are loaded. Add an owner-conditioned Deny case that first asserts the real endpoint returns 403, then asserts the AI context endpoint agrees. Verified: it returns 10 sample rows before the fix, none after. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> --------- Co-authored-by: Claude Opus 5 (1M context) <[email protected]> (cherry picked from commit 8298911) * fix(search): resolve DI indexes with the cluster data stream prefix * fix(ui): keep autocomplete responses with their own requests --------- Co-authored-by: Sriharsha Chintalapani <[email protected]> Co-authored-by: Vishnu Jain <[email protected]> Co-authored-by: Sriharsha Chintalapani <[email protected]> Co-authored-by: sonika-shah <[email protected]> Co-authored-by: Pere Miquel Brull <[email protected]> Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
…en-metadata#33126) open-metadata#32608 added `assetContext.table.sampleData` to the AI context but only the structured representation surfaced it. Markdown is the default for both `GET /{entity}/{id}/context` and the MCP `get_entity` tool, so the stored samples were reachable only via `?format=json` — the gap this closes. Renders a `# Sample Data` table under the SCHEMA section, immediately reusing the payload the builder already authorized against `ViewSampleData` and PII-masked. Values are flattened to one line, pipe escaped, padded/truncated to the declared column width, and capped at 120 chars so a blob column cannot crowd out the rest of the context. A caveat line marks the rows as a sample so an agent does not count or aggregate over them. The persona context path is unaffected: `AIContextBuilder.applySearchFields` indexes `buildTableContext(table)` without sample data, so the cached, cross-user persona document has nothing to render. Co-authored-by: Claude Opus 5 (1M context) <[email protected]>



Describe your changes:
Fixes #32600
Adds stored table samples to the structured per-entity AI context so SQL agents can inspect representative value shapes without first querying the warehouse.
The endpoint returns at most 10 rows, reuses the existing
ViewSampleDataauthorization, and applies the same PII masking asGET /tables/{id}/sampleData. If the caller cannot view samples—or stored data cannot be loaded—the rest of/contextstill succeeds without sample rows.Companion consumer: open-metadata/ai-platform#982.
Type of change:
High-level design:
sampleDatafield toassetContext.tableinaiContext.jsonand regenerates dependent TypeScript models.TableRepository.getSampleData(..., canViewPii)after the sameViewSampleDataand PII authorization checks used byTableResource.?format=jsonrepresentation.Tests:
Use cases covered
deny ViewSampleDatastill receives the context response, without sample rows.Unit tests
AIContextBuilderTest; 35 tests passed.Backend integration tests
AIContextRestIT; 7 tests passed against the HTTP endpoint.Ingestion integration tests
Playwright (UI) tests
Manual testing performed
mvn -pl openmetadata-spec -am install -DskipTestsmvn test -pl openmetadata-service -Dtest=AIContextBuilderTest -DfailIfNoTests=falsemvn test -pl openmetadata-integration-tests -Dtest=AIContextRestIT -DfailIfNoTests=falsemvn spotless:checkUI screen recording / screenshots:
Not applicable; there are no UI behavior changes.
Checklist:
Fixes <issue-number>: <short explanation>Fixes #<issue-number>above.Improvement