Repository navigation
Fixes #32656: correct topic/apiEndpoint fieldNames aggregation field and align APIEndpoint writer to mapping - #32724
Conversation
…and align APIEndpoint writer to mapping
|
Hi there 👋 Thanks for your contribution! The OpenMetadata team will review the PR shortly! Once it has been labeled as Let us know if you need any help! |
✅ Playwright Results — workflow succeededValidated commit ✅ 4501 passed · ❌ 0 failed · 🟡 9 flaky · ⏭️ 1 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) 50m 29s ⏱️ Max setup 4m 31s · max shard execution 19m 46s · max shard-job elapsed before upload 23m 1s · reporting 22s 🌐 219.22 requests/attempt · 2.23 app boots/UI scenario · 42.16% common-shard skew Optimization targets still in progress:
🟡 9 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 |
…endpoint-fieldnames-a-1c2a0c
| // aggregations are not re-merged), so existing installs only get the fix through this | ||
| // migration. | ||
| // Idempotent. | ||
| repairFieldNamesAggregations(); |
There was a problem hiding this comment.
Existing documents remain stale
On a normal v210 upgrade, the MySQL and PostgreSQL migrations retarget the stored aggregations to requestFieldNames and responseFieldNames, but they do not reindex existing apiEndpoint documents. Those documents retain the old snake_case fields, so unchanged endpoints continue returning empty field-name buckets until an operator runs the separate reindex command or the entity is updated.
| List<Aggregation> aggregations = apiEndpoint.getAggregations(); | ||
| // The apiEndpoint index mapping has no `fieldNames` field (it has `requestFieldNames` and | ||
| // `responseFieldNames`), so any `fieldNames` aggregation here is the stale misconfiguration. | ||
| boolean removed = aggregations.removeIf(agg -> FIELD_NAMES_AGG_NAME.equals(agg.getName())); |
There was a problem hiding this comment.
Valid custom aggregations deleted
This removes every apiEndpoint aggregation named fieldNames, rather than only the stale aggregation whose field is fieldsNames. Existing per-asset settings may contain persisted customizations, so an upgrade can silently delete a valid compatibility aggregation such as fieldNames targeting requestFieldNames. Restrict removal to the known stale name-and-field combination.
| List<String> responseKeys = | ||
| bucketKeys( | ||
| "api_endpoint_agg_en", | ||
| termsAggregation("respSchemaFields", "responseSchema.schemaFields.name.keyword")); |
There was a problem hiding this comment.
The new test instantiates java.util.ArrayList with a fully qualified class name. The repository's Java conventions require importing the class instead, so this requirement must be satisfied before merging.
Context Used: CLAUDE.md (source)
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
| LOG.info( | ||
| "No stale fieldNames aggregation found in stored search settings; no repair needed"); | ||
| } | ||
| } catch (Exception e) { |
There was a problem hiding this comment.
The new migration catches the broad Exception type. The repository's Java conventions prohibit catch (Exception e) and require catching the specific database, parsing, and resource-loading exception types, so this requirement must be satisfied before merging.
Context Used: CLAUDE.md (source)
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
…37994) 2.0's APIEndpointIndex writes an endpoint's response fields under response_field_names. The camel-case responseFieldNames key came with #32724 on main (writer aligned to the mapping, with a 2.1 migration), which 2.0 does not have. The backported test waited on the main-only key and timed out on every engine.
Detail bug report: View on Detail
Describe your changes:
Fixes #32656
I worked on the silent
fieldNamesaggregation misconfiguration insearchSettings.jsonbecause the topic and apiEndpoint asset configs declared a terms aggregation against"field": "fieldsNames"(an extras), a field that exists in no Elasticsearch/OpenSearch mapping and no Java writer. Terms aggregations on an unmapped field return no buckets without raising an error, so/v1/search/querysilently emittedfieldNames: { "buckets": [] }for every topic/apiEndpoint search. The apiEndpoint side additionally had a writer/mapping mismatch:APIEndpointIndexwroterequest_field_names/response_field_names(snake_case) whileapi_endpoint_index_mapping.jsondeclaredrequestFieldNames/responseFieldNames(camelCase) keyword fields that were never populated.Type of change:
High-level design:
searchSettings.json— corrected the topic aggregation to"field": "fieldNames"(the mapped keyword arrayTopicIndexalready writes). Replaced the single broken apiEndpointfieldNamesaggregation with two aggregations,requestFieldNamesandresponseFieldNames, pointing at the mapped camelCase keyword fields.APIEndpointIndex.java— aligns the writer to the mapping: it now putsrequestFieldNames/responseFieldNames(camelCase keyword, matchingapi_endpoint_index_mapping.json). The*_field_namesFuzzytext fields used for search relevance are unchanged, so the boosted ranking channel is untouched.SearchSettingsHandler#mergeAssetTypeConfigurationsonly adds missing asset types and never re-merges per-asset aggregations, so correcting the seed alone leaves upgraded clusters pointing at the stale field. AddedSearchAggregationFieldRepair(idempotent; precedent: v1132fixOwnerDisplayNameAggregation, v202SearchNameKeywordRepair) and hooked it into the existing in-developmentv210Migration.runDataMigration()for both mysql and postgres. It retargets the topicfieldNamesfield tofieldNamesand replaces the apiEndpointfieldNamesaggregation withrequestFieldNames+responseFieldNamesfrom the seed.SearchSettingsHandlerTest.everyConfiguredAggregationFieldExistsInItsIndexMapping, which resolves each configured aggregation field viaSearchSourceBuilderFactory.resolveFieldForSortOrAggregationand asserts it names a real path in that asset's index mapping (descending bothpropertiesand.keywordmulti-fields). Two same-class pre-existing misconfigurations the guard surfaced (query|queryType,glossaryTerm|status) are excluded via a self-maintainingpendingMappingFixallowlist that also fails if an entry becomes stale, so removing a fixed one is enforced. This is the durable guard the issue recommends; it catches the original typo if reintroduced.Tests:
Use cases covered
fieldNamesaggregation returns populated buckets (incl. flattened nested child field names) from the mapped keyword array the writer produces.requestFieldNames/responseFieldNamesaggregations return populated buckets from the mapped camelCase keyword fields after the writer is aligned; the oldfieldNamesaggregation key is gone.messageSchema.schemaFields.name.keyword,requestSchema.schemaFields.name.keyword,responseSchema.schemaFields.name.keyword) still return buckets — no regression.fieldNamesFuzzy/*_field_namesFuzzysearch-relevance channel is unchanged.fieldsNamesaggregation are repaired by the v210 migration, and a second migration pass makes no further change (idempotent).Unit tests
openmetadata-service/.../resources/system/SearchSettingsHandlerTest.java— neweveryConfiguredAggregationFieldExistsInItsIndexMapping+everyGlobalAggregationFieldExistsInAtLeastOneIndexMappingguards.openmetadata-service/.../migration/utils/v210/SearchAggregationFieldRepairTest.java— 8 cases: retarget topic, split apiEndpoint, idempotency, leave-correct-topic-alone, no-duplicate, added-when-stale-removed, empty settings, missing-asset-types.openmetadata-service/.../search/indexes/EntitySpecificFieldsTest.java— assertions updated for therequestFieldNames/responseFieldNameswriter rename.Backend integration tests
openmetadata-integration-tests/for new/changed API endpoints.openmetadata-integration-tests/.../tests/search/FieldNamesAggregationIT.java— indexes a real topic and apiEndpoint doc (carrying the writer's exact output) into the shippedenmappings in an OpenSearch container and asserts thefieldNames/requestFieldNames/responseFieldNames/messageSchema.schemaFields.name.keyword/requestSchema.schemaFields.name.keyword/responseSchema.schemaFields.name.keywordaggregations return the expected buckets, plus a negative control asserting the misspelledfieldsNamesaggregation returns no buckets (reproducing the original silent failure).Ingestion integration tests
Playwright (UI) tests
fieldNamesaggregation key — the schema-field facets are served by the correct first aggregation in each config, which is untouched).Manual testing performed
fieldsNamestypo is reintroduced, and restores green after revert.pendingMappingFixallowlist is self-maintaining in both directions: removing an entry while its field is still unmapped fails the enforcement assertion; keeping an entry after its field is retargeted to a mapped field fails the stale-allowlist assertion.SearchConsumerFieldBehaviorIT(20),HighlightFieldSaveValidationIT(4),LiveSearchSettingsChangeIT(1),PerEntitySearchDefaultsIT(1),CustomPropertyAggregationIT(2), and the newFieldNamesAggregationIT(5) — all pass.fieldsNamesvia the save path, run the repair, GET settings back) repairs the stored aggregations and is idempotent on a second pass (covered by the migration unit test's idempotency case).UI screen recording / screenshots:
Not applicable.
Checklist:
Fixes <issue-number>: <short explanation>Fixes #<issue-number>above.Bug fix
Automatic Fixes PRs can be configured here.
Greptile Summary
This PR aligns topic and apiEndpoint field-name aggregations with their index mappings, changes the apiEndpoint index writer to populate mapped camelCase keyword fields, and adds a v210 stored-settings repair plus regression tests.
Confidence Score: 3/5
The PR is not yet safe to merge because upgraded installations can retain empty apiEndpoint field-name buckets and the migration can delete valid customized aggregations.
The settings migration changes aggregation targets without rewriting existing documents, while its name-only removal predicate destructively treats every customized
fieldNamesaggregation as stale; two explicit Java conventions also remain unsatisfied.Files Needing Attention: openmetadata-service/src/main/java/org/openmetadata/service/migration/utils/v210/SearchAggregationFieldRepair.java, openmetadata-service/src/main/java/org/openmetadata/service/migration/mysql/v210/Migration.java, openmetadata-service/src/main/java/org/openmetadata/service/migration/postgres/v210/Migration.java, openmetadata-integration-tests/src/test/java/org/openmetadata/it/tests/search/FieldNamesAggregationIT.java
Important Files Changed
fieldNamesaggregations too broadly and violates the specific-exception rule.Flowchart
%%{init: {'theme': 'neutral'}}%% flowchart LR U[Upgrade to v210] --> M[Repair stored aggregation settings] M --> A[Aggregations target camelCase fields] D[Existing apiEndpoint documents] --> O[snake_case exact fields only] A --> E[Empty buckets for unchanged documents] O --> E R[Manual reindex or entity update] --> W[APIEndpointIndex rewrites document] W --> N[camelCase keyword fields populated] N --> B[Populated request/response buckets]Reviews (1): Last reviewed commit: "Merge branch 'main' into detail/bug-fix/..." | Re-trigger Greptile
Context used: