Skip to content

Add Unit Tests coverage#26360

Open
harshach wants to merge 121 commits intomainfrom
tests
Open

Add Unit Tests coverage#26360
harshach wants to merge 121 commits intomainfrom
tests

Conversation

@harshach
Copy link
Collaborator

@harshach harshach commented Mar 10, 2026

Describe your changes:

Fixes

I worked on ... because ...

Type of change:

  • Bug fix
  • Improvement
  • New feature
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation

Checklist:

  • I have read the CONTRIBUTING document.
  • My PR title is Fixes <issue-number>: <short explanation>
  • I have commented on my code, particularly in hard-to-understand areas.
  • For JSON Schema changes: I updated the migration scripts or explained why it is not needed.

Summary by Gitar

  • Unit test additions:
    • Added comprehensive unit tests for UserUtil class covering user creation, preference validation, and change event tracking
    • Created new UtilitiesTest covering date formatting, quote handling, and regex escape utilities
  • Code quality improvements:
    • Enhanced error handling in formatters (IngestionPipelineFormatter, PipelineFormatter) to handle malformed JSON gracefully
    • Added null-safety checks in notification decorators and formatters (MSTeams, Slack, GChat, Teams)
  • Coverage expansion in pom.xml:
    • Extended JaCoCo coverage includes to add formatter and notification packages
  • New coverage analysis tool:
    • Added jacoco_diff_coverage.py script for computing diff-based coverage metrics

This will update automatically on new commits.

# Conflicts:
#	openmetadata-service/pom.xml
#	openmetadata-service/src/main/java/org/openmetadata/service/search/security/RBACConditionEvaluator.java
#	openmetadata-service/src/main/java/org/openmetadata/service/util/SchemaFieldExtractor.java
#	openmetadata-service/src/test/java/org/openmetadata/service/monitoring/MetricsErrorHandlingTest.java
#	openmetadata-service/src/test/java/org/openmetadata/service/search/vector/VectorSearchQueryBuilderTest.java
@harshach harshach requested a review from a team as a code owner March 14, 2026 03:03
@github-actions
Copy link
Contributor

The Java checkstyle failed.

Please run mvn spotless:apply in the root of your repository and commit the changes to this PR.
You can also use pre-commit to automate the Java code formatting.

You can install the pre-commit hooks with make install_test precommit_install.

// where low-scoring neighbors may still be returned to fill the k count.
if (score < threshold) {
continue;
while (!exhausted && byParent.size() < requestedParents) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Bug: Vector search pagination loop may never terminate

The new pagination loop in searchVector iterates while (!exhausted && byParent.size() < requestedParents). When totalHits is unknown (-1, which happens when OpenSearch returns no hits.total), the exhaustion check at line 172 is pageHitCount < overFetchSize. If every page returns exactly overFetchSize raw hits but all of them score below threshold (so none are added to byParent), then:

  • pageHitCount == overFetchSizeexhausted = false
  • byParent.size() remains 0, never reaching requestedParents
  • The loop runs indefinitely, issuing unbounded requests to OpenSearch

This scenario is possible when a high threshold is set and the index contains many low-scoring documents. Even when totalHits >= 0, if the index is very large it could loop for an excessive number of iterations before rawOffset >= totalHits.

A maximum iteration cap (e.g., MAX_PAGES = 10) would prevent runaway loops in both cases.

Suggested fix:

// Add a max-page guard at the top of the method:
int maxPages = 10; // safety cap
int pageCount = 0;

while (!exhausted && byParent.size() < requestedParents && pageCount < maxPages) {
    pageCount++;
    // ... existing loop body ...
}

Was this helpful? React with 👍 / 👎 | Reply gitar fix to apply this suggestion

@github-actions
Copy link
Contributor

Jest test Coverage

UI tests summary

Lines Statements Branches Functions
Coverage: 66%
66.04% (57478/87031) 45.65% (30408/66606) 48.62% (9113/18742)

@github-actions
Copy link
Contributor

github-actions bot commented Mar 14, 2026

OpenMetadata Service New-Code Coverage

PASS. Required changed-line coverage: 90.00% overall and per touched production file.

  • Overall executable changed lines: 406/414 covered (98.07%)
  • Missed executable changed lines: 8
  • Non-executable changed lines ignored by JaCoCo: 213
  • Changed production files: 56
File Covered Missed Executable Non-exec Coverage Uncovered lines
openmetadata-service/src/main/java/org/openmetadata/service/search/vector/OpenSearchVectorService.java 39 4 43 22 90.70% 167, 168, 227, 232
openmetadata-service/src/main/java/org/openmetadata/service/search/ColumnMetadataCache.java 13 1 14 10 92.86% 160
openmetadata-service/src/main/java/org/openmetadata/service/clients/pipeline/k8s/K8sPipelineClient.java 28 2 30 13 93.33% 2246, 2254
openmetadata-service/src/main/java/org/openmetadata/service/apps/bundles/searchIndex/OpenSearchBulkSink.java 25 1 26 14 96.15% 1015
openmetadata-service/src/main/java/org/openmetadata/csv/EntityCsv.java 30 0 30 19 100.00% -
openmetadata-service/src/main/java/org/openmetadata/service/apps/bundles/searchIndex/ElasticSearchBulkSink.java 18 0 18 11 100.00% -
openmetadata-service/src/main/java/org/openmetadata/service/apps/bundles/searchIndex/ElasticSearchIndexSink.java 5 0 5 2 100.00% -
openmetadata-service/src/main/java/org/openmetadata/service/apps/bundles/searchIndex/IndexingPipeline.java 20 0 20 18 100.00% -
openmetadata-service/src/main/java/org/openmetadata/service/apps/bundles/searchIndex/OpenSearchIndexSink.java 5 0 5 2 100.00% -
openmetadata-service/src/main/java/org/openmetadata/service/apps/bundles/searchIndex/ReindexingOrchestrator.java 4 0 4 1 100.00% -
openmetadata-service/src/main/java/org/openmetadata/service/apps/bundles/searchIndex/distributed/DistributedSearchIndexExecutor.java 5 0 5 3 100.00% -
openmetadata-service/src/main/java/org/openmetadata/service/apps/bundles/searchIndex/distributed/JobRecoveryManager.java 5 0 5 2 100.00% -
openmetadata-service/src/main/java/org/openmetadata/service/apps/bundles/searchIndex/distributed/PartitionWorker.java 4 0 4 2 100.00% -
openmetadata-service/src/main/java/org/openmetadata/service/apps/bundles/searchIndex/listeners/QuartzProgressListener.java 2 0 2 0 100.00% -
openmetadata-service/src/main/java/org/openmetadata/service/clients/pipeline/config/types/ProfilerWorkflowConfig.java 8 0 8 1 100.00% -
openmetadata-service/src/main/java/org/openmetadata/service/formatter/decorators/MSTeamsMessageDecorator.java 4 0 4 2 100.00% -
openmetadata-service/src/main/java/org/openmetadata/service/formatter/decorators/SlackMessageDecorator.java 12 0 12 3 100.00% -
openmetadata-service/src/main/java/org/openmetadata/service/formatter/entity/IngestionPipelineFormatter.java 4 0 4 3 100.00% -
openmetadata-service/src/main/java/org/openmetadata/service/formatter/entity/PipelineFormatter.java 4 0 4 3 100.00% -
openmetadata-service/src/main/java/org/openmetadata/service/logstorage/S3LogStorage.java 10 0 10 3 100.00% -
openmetadata-service/src/main/java/org/openmetadata/service/migration/utils/v1105/MigrationUtil.java 12 0 12 6 100.00% -
openmetadata-service/src/main/java/org/openmetadata/service/migration/utils/v160/MigrationUtil.java 2 0 2 2 100.00% -
openmetadata-service/src/main/java/org/openmetadata/service/notifications/channels/gchat/GChatCardAssembler.java 4 0 4 1 100.00% -
openmetadata-service/src/main/java/org/openmetadata/service/notifications/channels/gchat/GChatMarkdownFormatter.java 3 0 3 1 100.00% -
openmetadata-service/src/main/java/org/openmetadata/service/notifications/channels/slack/SlackMarkdownFormatter.java 2 0 2 0 100.00% -
openmetadata-service/src/main/java/org/openmetadata/service/notifications/channels/teams/TeamsCardAssembler.java 1 0 1 0 100.00% -
openmetadata-service/src/main/java/org/openmetadata/service/notifications/channels/teams/TeamsMarkdownFormatter.java 1 0 1 0 100.00% -
openmetadata-service/src/main/java/org/openmetadata/service/notifications/template/handlebars/helpers/BuildEntityUrlHelper.java 5 0 5 7 100.00% -
openmetadata-service/src/main/java/org/openmetadata/service/notifications/template/handlebars/helpers/TruncateHelper.java 3 0 3 2 100.00% -
openmetadata-service/src/main/java/org/openmetadata/service/rules/RuleEngine.java 14 0 14 5 100.00% -
openmetadata-service/src/main/java/org/openmetadata/service/search/ColumnFilterMatcher.java 2 0 2 1 100.00% -
openmetadata-service/src/main/java/org/openmetadata/service/search/LineagePathPreserver.java 15 0 15 18 100.00% -
openmetadata-service/src/main/java/org/openmetadata/service/search/SearchClusterMetrics.java 2 0 2 0 100.00% -
openmetadata-service/src/main/java/org/openmetadata/service/search/SearchIndexUtils.java 4 0 4 3 100.00% -
openmetadata-service/src/main/java/org/openmetadata/service/search/SearchRepository.java 17 0 17 4 100.00% -
openmetadata-service/src/main/java/org/openmetadata/service/search/elasticsearch/ElasticSearchSourceBuilderFactory.java 1 0 1 0 100.00% -
openmetadata-service/src/main/java/org/openmetadata/service/search/elasticsearch/EsUtils.java 2 0 2 2 100.00% -
openmetadata-service/src/main/java/org/openmetadata/service/search/lineage/LineageGraphConfiguration.java 1 0 1 0 100.00% -
openmetadata-service/src/main/java/org/openmetadata/service/search/opensearch/OpenSearchSourceBuilderFactory.java 1 0 1 0 100.00% -
openmetadata-service/src/main/java/org/openmetadata/service/search/opensearch/OsUtils.java 2 0 2 2 100.00% -
openmetadata-service/src/main/java/org/openmetadata/service/search/security/RBACConditionEvaluator.java 7 0 7 1 100.00% -
openmetadata-service/src/main/java/org/openmetadata/service/search/vector/utils/DTOs.java 8 0 8 10 100.00% -
openmetadata-service/src/main/java/org/openmetadata/service/security/AuthenticationCodeFlowHandler.java 4 0 4 1 100.00% -
openmetadata-service/src/main/java/org/openmetadata/service/security/DefaultAuthorizer.java 4 0 4 1 100.00% -
openmetadata-service/src/main/java/org/openmetadata/service/security/SecurityUtil.java 3 0 3 2 100.00% -
openmetadata-service/src/main/java/org/openmetadata/service/security/auth/validator/AzureAuthValidator.java 2 0 2 3 100.00% -
openmetadata-service/src/main/java/org/openmetadata/service/security/auth/validator/SamlValidator.java 3 0 3 0 100.00% -
openmetadata-service/src/main/java/org/openmetadata/service/security/policyevaluator/PermissionDebugService.java 3 0 3 3 100.00% -
openmetadata-service/src/main/java/org/openmetadata/service/security/policyevaluator/RuleEvaluator.java 3 0 3 0 100.00% -
openmetadata-service/src/main/java/org/openmetadata/service/util/AsyncService.java 1 0 1 0 100.00% -
openmetadata-service/src/main/java/org/openmetadata/service/util/EntityFieldUtils.java 1 0 1 1 100.00% -
openmetadata-service/src/main/java/org/openmetadata/service/util/ODCSConverter.java 4 0 4 0 100.00% -
openmetadata-service/src/main/java/org/openmetadata/service/util/RestUtil.java 1 0 1 0 100.00% -
openmetadata-service/src/main/java/org/openmetadata/service/util/SchemaFieldExtractor.java 8 0 8 0 100.00% -
openmetadata-service/src/main/java/org/openmetadata/service/util/SubscriptionUtil.java 3 0 3 0 100.00% -
openmetadata-service/src/main/java/org/openmetadata/service/util/UserUtil.java 12 0 12 3 100.00% -

Only changed executable lines under openmetadata-service/src/main/java are counted. Test files, comments, imports, and non-executable lines are excluded.

@github-actions
Copy link
Contributor

github-actions bot commented Mar 14, 2026

🟡 Playwright Results — all passed (18 flaky)

✅ 3336 passed · ❌ 0 failed · 🟡 18 flaky · ⏭️ 183 skipped

Shard Passed Failed Flaky Skipped
🟡 Shard 1 453 0 2 2
✅ Shard 2 304 0 0 1
🟡 Shard 3 653 0 8 33
🟡 Shard 4 722 0 6 47
✅ Shard 5 591 0 0 67
🟡 Shard 6 613 0 2 33
🟡 18 flaky test(s) (passed on retry)
  • Flow/Metric.spec.ts › Verify Related Metrics Update (shard 1, 1 retry)
  • Pages/Customproperties-part1.spec.ts › Timestamp (shard 1, 1 retry)
  • Features/CustomPropertySearchSettings.spec.ts › Create custom properties and configure search for Dashboard (shard 3, 1 retry)
  • Features/DataQuality/ColumnLevelTests.spec.ts › Column Values Sum To Be Between (shard 3, 1 retry)
  • Features/DataQuality/IncidentManagerDateFilter.spec.ts › Clear selected date range (shard 3, 1 retry)
  • Features/DataQuality/TableLevelTests.spec.ts › Table Difference (shard 3, 1 retry)
  • Features/DataQuality/TestCaseIncidentPermissions.spec.ts › User with only VIEW cannot PATCH incidents (shard 3, 1 retry)
  • Features/DataQuality/TestCaseResultPermissions.spec.ts › User with only VIEW cannot PATCH results (shard 3, 1 retry)
  • Features/LandingPageWidgets/FollowingWidget.spec.ts › Check followed entity present in following widget (shard 3, 1 retry)
  • Features/Permissions/GlossaryPermissions.spec.ts › Team-based permissions work correctly (shard 3, 1 retry)
  • Flow/ObservabilityAlerts.spec.ts › Alert operations for a user with and without permissions (shard 4, 1 retry)
  • Pages/Customproperties-part2.spec.ts › entityReferenceList shows item count, scrollable list, no expand toggle (shard 4, 1 retry)
  • Pages/Domains.spec.ts › Rename domain with tags and glossary terms preserves associations (shard 4, 1 retry)
  • Pages/Entity.spec.ts › Tag and Glossary Term preservation in column detail panel (shard 4, 1 retry)
  • Pages/Entity.spec.ts › Glossary Term Add, Update and Remove for child entities (shard 4, 1 retry)
  • Pages/Entity.spec.ts › Glossary Term Add, Update and Remove (shard 4, 1 retry)
  • Pages/Users.spec.ts › Permissions for table details page for Data Consumer (shard 6, 1 retry)
  • VersionPages/EntityVersionPages.spec.ts › Directory (shard 6, 1 retry)

📦 Download artifacts

How to debug locally
# Download playwright-test-results-<shard> artifact and unzip
npx playwright show-trace path/to/trace.zip    # view trace

@sonarqubecloud
Copy link

mohityadav766
mohityadav766 previously approved these changes Mar 18, 2026
Copy link
Member

@mohityadav766 mohityadav766 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good

@sonarqubecloud
Copy link

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR significantly expands Java unit test coverage (especially around formatters and search-indexing/distributed reindexing) while hardening several production paths via improved null-safety, error handling, and more resilient search/vector/reindexing behaviors.

Changes:

  • Added a large suite of unit tests across formatters, notification decorators, and search-indexing/distributed reindexing components.
  • Improved runtime robustness (null-safety, malformed JSON fallbacks, safer list copying, cursor parsing, cycle protection for lineage filtering, etc.).
  • Updated CI to run service unit tests with JaCoCo reporting and PR diff-coverage enforcement.

Reviewed changes

Copilot reviewed 118 out of 201 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
openmetadata-service/src/test/java/org/openmetadata/service/formatter/field/TagFormatterTest.java Adds unit tests for tag field formatting behavior.
openmetadata-service/src/test/java/org/openmetadata/service/formatter/field/OwnerFormatterTest.java Adds unit tests for owner field formatting behavior.
openmetadata-service/src/test/java/org/openmetadata/service/formatter/field/DefaultFieldFormatterTest.java Adds unit tests for default field formatting and parsing.
openmetadata-service/src/test/java/org/openmetadata/service/formatter/entity/PipelineFormatterTest.java Adds tests for pipeline status formatting and malformed payload fallback.
openmetadata-service/src/test/java/org/openmetadata/service/formatter/entity/IngestionPipelineFormatterTest.java Adds tests for ingestion pipeline formatting and URL helpers.
openmetadata-service/src/test/java/org/openmetadata/service/formatter/decorators/PlatformMessageDecoratorTest.java Adds tests for Slack/GChat/Teams/feed decorators.
openmetadata-service/src/test/java/org/openmetadata/service/formatter/decorators/EmailMessageDecoratorTest.java Adds tests for email message mapping and validation.
openmetadata-service/src/test/java/org/openmetadata/service/formatter/TestMessageDecorator.java Introduces a minimal decorator for formatter unit tests.
openmetadata-service/src/test/java/org/openmetadata/service/clients/pipeline/config/WorkflowConfigBuilderTest.java Makes YAML assertions less brittle by using contains checks.
openmetadata-service/src/test/java/org/openmetadata/service/apps/bundles/searchIndex/stats/StageStatsTrackerTest.java Adjusts thresholds/concurrency test parameters.
openmetadata-service/src/test/java/org/openmetadata/service/apps/bundles/searchIndex/stats/JobStatsManagerTest.java Adds coverage for job stats tracking/DAO behavior.
openmetadata-service/src/test/java/org/openmetadata/service/apps/bundles/searchIndex/stats/EntityStatsTrackerTest.java Adds coverage for flush behavior, retries, and bookkeeping.
openmetadata-service/src/test/java/org/openmetadata/service/apps/bundles/searchIndex/listeners/SlackProgressListenerTest.java Adds tests for Slack listener lifecycle and helpers.
openmetadata-service/src/test/java/org/openmetadata/service/apps/bundles/searchIndex/listeners/LoggingProgressListenerTest.java Adds tests for logging listener behavior and helpers.
openmetadata-service/src/test/java/org/openmetadata/service/apps/bundles/searchIndex/distributed/ServerIdentityResolverTest.java Adds tests for server identity selection and fallbacks.
openmetadata-service/src/test/java/org/openmetadata/service/apps/bundles/searchIndex/distributed/PollingJobNotifierTest.java Adds tests for polling notifier lifecycle and polling logic.
openmetadata-service/src/test/java/org/openmetadata/service/apps/bundles/searchIndex/distributed/PartitionCalculatorTest.java Updates DAO call usage and adds more partitioning/TS coverage.
openmetadata-service/src/test/java/org/openmetadata/service/apps/bundles/searchIndex/distributed/OrphanJobMonitorTest.java Adds monitor lifecycle and recovery-path coverage.
openmetadata-service/src/test/java/org/openmetadata/service/apps/bundles/searchIndex/distributed/JobRecoveryManagerTest.java Expands tests for new lock acquisition/stopping-job behaviors.
openmetadata-service/src/test/java/org/openmetadata/service/apps/bundles/searchIndex/distributed/EntityCompletionTrackerTest.java Adds reconcile/promotion behavior tests.
openmetadata-service/src/test/java/org/openmetadata/service/apps/bundles/searchIndex/distributed/DistributedJobNotifierFactoryTest.java Adds factory selection + utility ctor coverage.
openmetadata-service/src/test/java/org/openmetadata/service/apps/bundles/searchIndex/distributed/DistributedJobContextTest.java Adds distributed job context metadata tests.
openmetadata-service/src/test/java/org/openmetadata/service/apps/bundles/searchIndex/SingleServerIndexingStrategyTest.java Adds delegation/stop/stats tests.
openmetadata-service/src/test/java/org/openmetadata/service/apps/bundles/searchIndex/SearchIndexStatsTest.java Refactors backpressure/payload-too-large tests to bulk processor methods.
openmetadata-service/src/test/java/org/openmetadata/service/apps/bundles/searchIndex/SearchIndexMetricsTest.java Adds metrics registration/refresh behavior tests.
openmetadata-service/src/test/java/org/openmetadata/service/apps/bundles/searchIndex/SearchIndexFailureScenarioTest.java Updates failure scenario tests to use bulk processor retry logic.
openmetadata-service/src/test/java/org/openmetadata/service/apps/bundles/searchIndex/SearchIndexAppTest.java Adds tests for orchestrator delegation and config validation.
openmetadata-service/src/test/java/org/openmetadata/service/apps/bundles/searchIndex/ReindexingJobLoggerTest.java Adds coverage for logging helpers and state tracking.
openmetadata-service/src/test/java/org/openmetadata/service/apps/bundles/searchIndex/QuartzOrchestratorContextTest.java Adds tests for Quartz orchestrator context storage/factories.
openmetadata-service/src/test/java/org/openmetadata/service/apps/bundles/searchIndex/QuartzJobContextTest.java Adds tests for Quartz job context defaults and metadata.
openmetadata-service/src/test/java/org/openmetadata/service/apps/bundles/searchIndex/OrphanedIndexCleanerTest.java Adds tests for orphan index detection and cleanup behavior.
openmetadata-service/src/test/java/org/openmetadata/service/apps/bundles/searchIndex/IndexingFailureRecorderTest.java Updates expectations for reader batch failure stage/IDs.
openmetadata-service/src/test/java/org/openmetadata/service/apps/bundles/searchIndex/EntityReaderLifecycleTest.java Adds tests covering reader lifecycles and cursor boundaries.
openmetadata-service/src/test/java/org/openmetadata/service/apps/bundles/searchIndex/CompositeProgressListenerTest.java Adds ordering + fault-isolation tests for composite listener.
openmetadata-service/src/test/java/org/openmetadata/csv/CsvUtilTest.java Adds extensive coverage for CSV formatting/parsing/extension helpers.
openmetadata-service/src/main/java/org/openmetadata/service/util/UserUtil.java Adjusts bootstrap user loop handling and role sync mutability/flags.
openmetadata-service/src/main/java/org/openmetadata/service/util/SubscriptionUtil.java Fixes header builder to return prepared builder; adds receiver validation checks.
openmetadata-service/src/main/java/org/openmetadata/service/util/SchemaFieldExtractor.java Updates entity exclusions, ref-type mapping, and entity subdirectory mapping.
openmetadata-service/src/main/java/org/openmetadata/service/util/RestUtil.java Changes date comparison parsing strategy.
openmetadata-service/src/main/java/org/openmetadata/service/util/ODCSConverter.java Adds null-safe entity name resolution and SLA timezone initialization.
openmetadata-service/src/main/java/org/openmetadata/service/util/EntityFieldUtils.java Avoids mutating entity tag list by copying before modification.
openmetadata-service/src/main/java/org/openmetadata/service/util/AsyncService.java Improves timeout detection in exceptionally handler.
openmetadata-service/src/main/java/org/openmetadata/service/security/policyevaluator/RuleEvaluator.java Simplifies domain matching by delegating to subject context hierarchy check.
openmetadata-service/src/main/java/org/openmetadata/service/security/policyevaluator/PermissionDebugService.java Normalizes effect handling via helper; adds null-safe mapping.
openmetadata-service/src/main/java/org/openmetadata/service/security/auth/validator/SamlValidator.java Improves IdP entity ID error mapping for more IdP message variants.
openmetadata-service/src/main/java/org/openmetadata/service/security/auth/validator/AzureAuthValidator.java Adds early GUID-format validation for Azure client ID.
openmetadata-service/src/main/java/org/openmetadata/service/security/SecurityUtil.java Adds support for displayName claim casing variant.
openmetadata-service/src/main/java/org/openmetadata/service/security/DefaultAuthorizer.java Improves impersonation checks and messaging when bot user missing.
openmetadata-service/src/main/java/org/openmetadata/service/security/AuthenticationCodeFlowHandler.java Adds null-safe client auth method and propagates PKCE disable flag for Azure.
openmetadata-service/src/main/java/org/openmetadata/service/search/vector/utils/DTOs.java Extends vector search response DTO with totalHits/hasMore and constructors.
openmetadata-service/src/main/java/org/openmetadata/service/search/vector/OpenSearchVectorService.java Updates init signature and adds parent-group pagination + totalHits/hasMore.
openmetadata-service/src/main/java/org/openmetadata/service/search/security/RBACConditionEvaluator.java Adds null-safe search repository handling when building index filter.
openmetadata-service/src/main/java/org/openmetadata/service/search/opensearch/OsUtils.java Uses JacksonJsonpMapper for JsonData conversions.
openmetadata-service/src/main/java/org/openmetadata/service/search/opensearch/OpenSearchSourceBuilderFactory.java Makes aggregation handling null-safe via listOrEmpty.
openmetadata-service/src/main/java/org/openmetadata/service/search/lineage/LineageGraphConfiguration.java Enables lineage caching by default with TTL/max settings.
openmetadata-service/src/main/java/org/openmetadata/service/search/elasticsearch/EsUtils.java Uses JacksonJsonpMapper for JsonData conversions.
openmetadata-service/src/main/java/org/openmetadata/service/search/elasticsearch/ElasticSearchSourceBuilderFactory.java Makes aggregation handling null-safe via listOrEmpty.
openmetadata-service/src/main/java/org/openmetadata/service/search/SearchRepository.java Adds resilience to doc build failures, fixes index naming, and tag propagation params.
openmetadata-service/src/main/java/org/openmetadata/service/search/SearchIndexUtils.java Improves field removal by path (single-key fast path, safer list item casting).
openmetadata-service/src/main/java/org/openmetadata/service/search/SearchClusterMetrics.java Adjusts conservative defaults calculation for content length and payload sizing.
openmetadata-service/src/main/java/org/openmetadata/service/search/LineagePathPreserver.java Adds cycle protection and preserves intermediate nodes for column filtering.
openmetadata-service/src/main/java/org/openmetadata/service/search/ColumnMetadataCache.java Fixes cache keying to use column FQN vs name and improves fallback handling.
openmetadata-service/src/main/java/org/openmetadata/service/search/ColumnFilterMatcher.java Rejects empty filter type/value criteria more safely.
openmetadata-service/src/main/java/org/openmetadata/service/rules/RuleEngine.java Makes rule loading more resilient when settings/repositories are unavailable.
openmetadata-service/src/main/java/org/openmetadata/service/notifications/template/handlebars/helpers/TruncateHelper.java Fixes truncation semantics and edge case handling.
openmetadata-service/src/main/java/org/openmetadata/service/notifications/template/handlebars/helpers/BuildEntityUrlHelper.java Makes base URL overridable and updates ingestion pipeline URL behavior.
openmetadata-service/src/main/java/org/openmetadata/service/notifications/channels/teams/TeamsMarkdownFormatter.java Tightens Teams link URL validation behavior.
openmetadata-service/src/main/java/org/openmetadata/service/notifications/channels/teams/TeamsCardAssembler.java Tightens Teams link URL validation behavior.
openmetadata-service/src/main/java/org/openmetadata/service/notifications/channels/slack/SlackMarkdownFormatter.java Fixes image alt-text rendering isolation.
openmetadata-service/src/main/java/org/openmetadata/service/notifications/channels/gchat/GChatMarkdownFormatter.java Improves image alt/title selection fallbacks.
openmetadata-service/src/main/java/org/openmetadata/service/notifications/channels/gchat/GChatCardAssembler.java Improves image alt/title selection fallbacks.
openmetadata-service/src/main/java/org/openmetadata/service/migration/utils/v160/MigrationUtil.java Null-safe rules list initialization when updating org policy.
openmetadata-service/src/main/java/org/openmetadata/service/migration/utils/v1105/MigrationUtil.java Applies JSON structural equality to avoid no-op workflow updates.
openmetadata-service/src/main/java/org/openmetadata/service/logstorage/S3LogStorage.java Adds cursor parse safety and cleans caches on deleteAllLogs.
openmetadata-service/src/main/java/org/openmetadata/service/formatter/entity/PipelineFormatter.java Handles malformed JSON status payloads gracefully.
openmetadata-service/src/main/java/org/openmetadata/service/formatter/entity/IngestionPipelineFormatter.java Handles malformed JSON status payloads gracefully.
openmetadata-service/src/main/java/org/openmetadata/service/formatter/decorators/SlackMessageDecorator.java Avoids adding entity link blocks when URL missing.
openmetadata-service/src/main/java/org/openmetadata/service/formatter/decorators/MSTeamsMessageDecorator.java Avoids adding entity link blocks when URL missing.
openmetadata-service/src/main/java/org/openmetadata/service/clients/pipeline/k8s/K8sPipelineClient.java Enforces Kubernetes name length + improves run ID derivation.
openmetadata-service/src/main/java/org/openmetadata/service/clients/pipeline/config/types/ProfilerWorkflowConfig.java Skips null metrics and omits empty profiler config.
openmetadata-service/src/main/java/org/openmetadata/service/apps/bundles/searchIndex/listeners/QuartzProgressListener.java Uses typed fields for stats/failure contexts.
openmetadata-service/src/main/java/org/openmetadata/service/apps/bundles/searchIndex/distributed/PartitionWorker.java Adds early stop/interrupt short-circuit and sets PROCESSING status on progress.
openmetadata-service/src/main/java/org/openmetadata/service/apps/bundles/searchIndex/distributed/JobRecoveryManager.java Adjusts lock handling and makes recovery result explicit.
openmetadata-service/src/main/java/org/openmetadata/service/apps/bundles/searchIndex/distributed/DistributedSearchIndexExecutor.java Ensures notifier triggers only when this server transitions job to RUNNING.
openmetadata-service/src/main/java/org/openmetadata/service/apps/bundles/searchIndex/ReindexingOrchestrator.java Ensures success context is reused/initialized before adding stats.
openmetadata-service/src/main/java/org/openmetadata/service/apps/bundles/searchIndex/OpenSearchIndexSink.java Improves batching and conversion failure accounting.
openmetadata-service/src/main/java/org/openmetadata/service/apps/bundles/searchIndex/OpenSearchBulkSink.java Routes permanent failures through unified recorder + metrics adjustments.
openmetadata-service/src/main/java/org/openmetadata/service/apps/bundles/searchIndex/IndexingPipeline.java Improves total counting for TS entities and optional time-window filtering.
openmetadata-service/src/main/java/org/openmetadata/service/apps/bundles/searchIndex/ElasticSearchIndexSink.java Improves batching and conversion failure accounting.
openmetadata-service/src/main/java/org/openmetadata/service/apps/bundles/searchIndex/ElasticSearchBulkSink.java Routes permanent failures through unified recorder.
openmetadata-service/src/main/java/org/openmetadata/csv/EntityCsv.java Hardens CSV doc loading and improves dry-run parent column hierarchy creation.
openmetadata-service/pom.xml Pins JUnit engine/params version and overrides surefire includes.
openmetadata-integration-tests/src/test/java/org/openmetadata/it/tests/VectorEmbeddingIntegrationIT.java Updates vector service init call signature.
CLAUDE.md Updates ingestion Python version guidance.
.github/workflows/openmetadata-service-unit-tests.yml Adds/updates unit-test workflow with change detection and diff coverage gate.

}

private String normalizeEffect(Rule.Effect effect) {
return effect == null ? null : effect.name();
Comment on lines +358 to 361
if (action.getReceivers() == null || action.getReceivers().isEmpty()) {
throw new IllegalArgumentException(
"Email Alert Invoked with Illegal Type and Settings. Emtpy or Null Users Recipients List");
}
Comment on lines 227 to 237
@Test
@DisplayName("Should NOT detect normal errors as backpressure")
void testNormalErrorsNotBackpressure() throws Exception {
Method method =
SearchIndexExecutor.class.getDeclaredMethod("isBackpressureError", String.class);
method.setAccessible(true);

assertFalse((boolean) method.invoke(executor, "Index not found"));
assertFalse((boolean) method.invoke(executor, "Document parsing exception"));
assertFalse((boolean) method.invoke(executor, "Mapping error"));
assertFalse((boolean) method.invoke(executor, (String) null));
ElasticSearchBulkSink.CustomBulkProcessor processor =
getCustomBulkProcessor(new ElasticSearchBulkSink(searchRepository, 10, 2, 1000000L));

assertFalse(invokeShouldRetry(processor, 0, "Index not found"));
assertFalse(invokeShouldRetry(processor, 0, "Document parsing exception"));
assertFalse(invokeShouldRetry(processor, 0, "Mapping error"));
assertTrue(invokeShouldRetry(processor, 0, null));
}
Comment on lines 130 to 135
int totalEntities = entities.size();
int failedEntities = entityErrorList.size();
int successfulEntities = totalEntities - failedEntities;
updateStats(successfulEntities, failedEntities);

if (!entityErrorList.isEmpty()) {
throw new SearchIndexException(
Comment on lines +885 to +890
"Issue in building search document for entity [{}] and entityType [{}]. Reason[{}], Cause[{}], Stack [{}]",
entity.getId(),
entityType,
ie.getMessage(),
ie.getCause(),
ExceptionUtils.getStackTrace(ie));
Comment on lines 31 to +34
<logback-classic.version>1.5.25</logback-classic.version>
<resilience4j-ratelimiter.version>2.3.0</resilience4j-ratelimiter.version>
<kubernetes-client.version>24.0.0</kubernetes-client.version>
<junit.jupiter.service.version>5.11.2</junit.jupiter.service.version>

// createEntities is async fire-and-forget — errors are handled in its
// callback via the retry queue, so no try-catch is needed here.
Timer.Sample searchSample = RequestLatencyContext.startSearchOperation();
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚨 Bug: createEntitiesIndex has duplicate variable + malformed try block

The createEntitiesIndex method has at least two compile-breaking issues introduced by this commit:

  1. Duplicate local variable: Timer.Sample searchSample is declared at line 858 (in the if block scope) and again at line 898 (inside the nested try block). Java does not allow a local variable in a nested scope to shadow a local variable from an enclosing scope within the same method — this is a compile error.

  2. try without catch/finally: The outer try { at line 859 has no matching catch or finally clause. The } finally { at line 905 belongs to the inner try at line 899, leaving the outer try structurally invalid.

This appears to be a bad merge: the original code had a single Timer.Sample searchSample + try/catch/finally block. The new code added an outer try and moved searchSample earlier, but the old searchSample declaration and inner try/finally were also retained, creating overlapping broken structures.

The fix is to remove the duplicate Timer.Sample searchSample at line 898 and the inner try { at line 899, keeping only the outer try-finally that wraps the entire operation.

Suggested fix:

Remove the duplicate variable and inner try block. The outer try-finally should wrap everything:

// Remove line 898: Timer.Sample searchSample = ...
// Remove line 899: try {
// Remove lines 905-907: } finally { ... }
// Add finally to the outer try at line 859:
//   } finally {
//     RequestLatencyContext.endSearchOperation(searchSample);
//   }

Was this helpful? React with 👍 / 👎 | Reply gitar fix to apply this suggestion

@gitar-bot
Copy link

gitar-bot bot commented Mar 19, 2026

Analyzing CI failures

🔍 CI failure analysis for b21402e: Unit test coverage expansion in search indexing and service modules faces multiple infrastructure and test execution issues: integration test environment setup logs truncated mid-pip-installation preventing verification of test readiness; 45 unique error patterns detected across 58 analyzed logs suggesting systemic problems with test harness, mocking, or dependency configuration rather than code changes.

Overview

Analyzed 58 CI logs across 45 unique error templates from a large unit test coverage expansion PR. The PR adds ~20,000 LOC of new tests across search indexing (distributed strategies, bulk processing), service integrations (Slack, Teams, GChat), security validators, and utility modules. While diff changes appear focused and targeted (mainly test additions), the CI results show significant infrastructure and test infrastructure issues rather than localized test failures. A critical finding is that integration test environment setup logs are truncated during Python dependency installation, preventing full assessment of test environment readiness.

Failures

Integration Test Environment Setup Incomplete (confidence: high)

  • Type: infrastructure
  • Affected jobs: integration-tests-mysql-elasticsearch (shard-1, 3.10)
  • Related to change: unclear
  • Root cause: CI log truncation during pip dependency installation phase. The log shows successful Docker build, system package installation, and most Python dependencies downloaded, but ends abruptly mid-installation of openmetadata-ingestion and transitive dependencies. No indication of whether test environment reached ready state or if setup failed.
  • Suggested fix: (1) Retrieve full CI logs from affected job to determine if environment setup completed; (2) if truncation is real, check Docker build logs for OOM kills or timeout issues; (3) verify pip cache and dependency resolution completed without errors; (4) confirm all required system libs (librdkafka-dev, libsasl2-dev, etc.) installed

Multiple Error Template Patterns Across Test Suite (confidence: medium)

  • Type: test, configuration
  • Affected jobs: 58 logs analyzed with 45 unique error patterns
  • Related to change: yes
  • Root cause: The sheer volume of unique error patterns (45 templates across 58 logs) suggests either: (a) mock/stub configuration issues affecting many test classes; (b) test harness setup problems (JUnit lifecycle, test context initialization); (c) dependency injection or Spring context problems in new test classes; or (d) race conditions in concurrent test execution. The PR adds 15+ new test classes with heavy mocking (SearchIndexAppTest, DistributedSearchIndexExecutorTest, etc.), which increases surface area for configuration issues.
  • Suggested fix: (1) Review new test class @SpringBootTest or @ExtendWith annotations for missing configurations; (2) audit mock setup in common test fixtures (e.g., test base classes, @BeforeEach/@BeforeAll methods); (3) check if new tests use incompatible mock frameworks or conflicting dependency versions; (4) run subset of new tests locally with verbose logging to isolate pattern

Search Indexing Test Coverage Expansion (confidence: high)

  • Type: test
  • Affected jobs: Related to new test classes: ElasticSearchBulkSinkBehaviorTest, OpenSearchBulkSinkBehaviorTest, DistributedSearchIndexExecutorTest, SearchIndexExecutorControlFlowTest
  • Related to change: yes
  • Root cause: PR adds comprehensive test coverage for search indexing pipelines, bulk operations, and distributed execution. While code changes in source (ElasticSearchBulkSink.java, OpenSearchBulkSink.java, etc.) appear defensive (null checks, retry logic), new tests likely expose edge cases or setup issues not caught in simpler existing tests.
  • Suggested fix: (1) Verify Elasticsearch/OpenSearch mock clients are properly initialized in test setup; (2) check if bulk processor mocks handle concurrent/async operations correctly; (3) review if PartitionWorker and distributed coordinator tests properly mock inter-process communication; (4) ensure test data (index mappings, documents) match schema expectations

Service Integration Test Coverage (confidence: medium)

  • Type: test
  • Affected jobs: Related to new formatter/notification tests: SlackProgressListenerTest, MessageDecoratorTest, GChatCardAssemblerTest, TeamsCardAssemblerTest
  • Related to change: yes
  • Root cause: PR adds extensive tests for notification formatters and decorators (Slack, Teams, GChat, email). These tests likely mock external APIs and string formatting logic. Failures may stem from: (a) mock HTTP clients not configured for all request types; (b) JSON serialization mismatches; (c) missing test data for complex payloads.
  • Suggested fix: (1) Verify WireMock or HttpClientMock properly configured for all API endpoints; (2) review if new card/message builders handle null/empty fields gracefully; (3) ensure test data covers both minimal and complex message scenarios; (4) check if decorator test fixtures properly initialize dependent services

Security and Authorization Test Coverage (confidence: medium)

  • Type: test, configuration
  • Affected jobs: Related to new security tests: AuthenticationCodeFlowHandlerTest, CustomOidcValidatorTest, SamlValidatorTest, PIIMaskerTest, PermissionDebugServiceTest
  • Related to change: yes
  • Root cause: PR adds tests for OAuth flow handlers, OIDC/SAML validators, and RBAC/PII masking. These tests involve cryptographic operations, token generation, and policy evaluation. Failures likely relate to: (a) incomplete JWT/token mock setup; (b) missing crypto providers or certificates in test environment; (c) RBAC policy evaluation hitting edge cases.
  • Suggested fix: (1) Verify JWT test fixtures include all required claims; (2) check if OIDC discovery mocks return complete metadata; (3) audit SAML assertion builders for required attributes; (4) ensure PII masking rules cover all entity types in test data; (5) confirm test environment has necessary crypto libraries (BouncyCastle, etc.)

Summary

  • Change-related failures: Majority of the 45 error patterns appear tied to new test classes (15+ additions) lacking proper mock/fixture setup or encountering edge cases in search indexing, notifications, and security domains. The scope of coverage expansion (20k LOC) increases complexity significantly.
  • Infrastructure/flaky failures: Integration test environment setup is incomplete/truncated in logs, preventing verification of test readiness. This is a critical blocker for any integration test execution.
  • Recommended action: (1) Immediate: Obtain full CI logs to confirm test environment setup succeeded or identify failure point. (2) Short-term: Run new test classes locally in isolation with debug logging to identify mock/fixture issues; focus on base test classes and common fixtures shared across 15+ new tests. (3) Medium-term: Add comprehensive integration tests for mock setup (verify Spring context loads all required beans) and test harness validation before test execution. (4) Review: Ask reviewers to validate mock/fixture patterns align with existing test standards in codebase before merging.
Code Review 🚫 Blocked 7 resolved / 9 findings

Unit test coverage expansion introduces a critical blocker: createEntitiesIndex has duplicate variable declarations and a malformed try block causing compilation failures, alongside an important issue where the vector search pagination loop may never terminate.

🚨 Bug: createEntitiesIndex has duplicate variable + malformed try block

📄 openmetadata-service/src/main/java/org/openmetadata/service/search/SearchRepository.java:858 📄 openmetadata-service/src/main/java/org/openmetadata/service/search/SearchRepository.java:898 📄 openmetadata-service/src/main/java/org/openmetadata/service/search/SearchRepository.java:859

The createEntitiesIndex method has at least two compile-breaking issues introduced by this commit:

  1. Duplicate local variable: Timer.Sample searchSample is declared at line 858 (in the if block scope) and again at line 898 (inside the nested try block). Java does not allow a local variable in a nested scope to shadow a local variable from an enclosing scope within the same method — this is a compile error.

  2. try without catch/finally: The outer try { at line 859 has no matching catch or finally clause. The } finally { at line 905 belongs to the inner try at line 899, leaving the outer try structurally invalid.

This appears to be a bad merge: the original code had a single Timer.Sample searchSample + try/catch/finally block. The new code added an outer try and moved searchSample earlier, but the old searchSample declaration and inner try/finally were also retained, creating overlapping broken structures.

The fix is to remove the duplicate Timer.Sample searchSample at line 898 and the inner try { at line 899, keeping only the outer try-finally that wraps the entire operation.

Suggested fix
Remove the duplicate variable and inner try block. The outer try-finally should wrap everything:

// Remove line 898: Timer.Sample searchSample = ...
// Remove line 899: try {
// Remove lines 905-907: } finally { ... }
// Add finally to the outer try at line 859:
//   } finally {
//     RequestLatencyContext.endSearchOperation(searchSample);
//   }
⚠️ Bug: Vector search pagination loop may never terminate

📄 openmetadata-service/src/main/java/org/openmetadata/service/search/vector/OpenSearchVectorService.java:154 📄 openmetadata-service/src/main/java/org/openmetadata/service/search/vector/OpenSearchVectorService.java:172

The new pagination loop in searchVector iterates while (!exhausted && byParent.size() < requestedParents). When totalHits is unknown (-1, which happens when OpenSearch returns no hits.total), the exhaustion check at line 172 is pageHitCount < overFetchSize. If every page returns exactly overFetchSize raw hits but all of them score below threshold (so none are added to byParent), then:

  • pageHitCount == overFetchSizeexhausted = false
  • byParent.size() remains 0, never reaching requestedParents
  • The loop runs indefinitely, issuing unbounded requests to OpenSearch

This scenario is possible when a high threshold is set and the index contains many low-scoring documents. Even when totalHits >= 0, if the index is very large it could loop for an excessive number of iterations before rawOffset >= totalHits.

A maximum iteration cap (e.g., MAX_PAGES = 10) would prevent runaway loops in both cases.

Suggested fix
// Add a max-page guard at the top of the method:
int maxPages = 10; // safety cap
int pageCount = 0;

while (!exhausted && byParent.size() < requestedParents && pageCount < maxPages) {
    pageCount++;
    // ... existing loop body ...
}
✅ 7 resolved
Bug: SubscriptionUtil.getTarget discarded webhook HMAC headers (good fix)

📄 openmetadata-service/src/main/java/org/openmetadata/service/util/SubscriptionUtil.java:491
This is confirming the fix is correct and important. The old code at line 491 called SecurityUtil.addHeaders(target, authHeaders) a second time, which creates a new Invocation.Builder from the raw WebTarget, discarding the HMAC signature and custom webhook headers that prepareWebhookHeaders had just set on result. This means webhook authentication via HMAC signatures was silently broken — webhooks would be sent without the X-OM-Signature header. The fix to return result is correct.

No action needed — just highlighting this was a real production bug fix that should be called out in release notes.

Edge Case: TruncateHelper Javadoc still references old maxLength-3 logic

📄 openmetadata-service/src/main/java/org/openmetadata/service/notifications/template/handlebars/helpers/TruncateHelper.java:62
The truncation fix from maxLength - 3 to maxLength - 1 is correct (the ellipsis '…' is a single Unicode character, not 3 chars). However, the Javadoc at the top of the class/method still describes the old behavior with maxLength - 3 and "..." (three dots). This will mislead future developers.

Bug: getCsvDocumentation returns null but callers dereference without null check

📄 openmetadata-service/src/main/java/org/openmetadata/csv/EntityCsv.java:326 📄 openmetadata-service/src/main/java/org/openmetadata/service/search/security/RBACConditionEvaluator.java:385
The new early-return return null at EntityCsv.java:326 when jsonDataFiles.isEmpty() introduces a null return path that existing callers do not handle. Multiple subclasses chain .getHeaders() directly on the return value (e.g., getCsvDocumentation(...).getHeaders() in DriveServiceRepository, DatabaseRepository, DatabaseSchemaRepository, DatabaseServiceRepository), which will throw a NullPointerException. The previous behavior threw IndexOutOfBoundsException at jsonDataFiles.get(0), which at least had a clear stack trace. The new NPE is less informative and occurs at the caller site.

Either throw an exception instead of returning null (preserving fail-fast behavior with a clear message), or update all callers to handle null.

Edge Case: RuleEngine catches broad Exception in getEnabledEntitySemantics

📄 openmetadata-service/src/main/java/org/openmetadata/service/rules/RuleEngine.java:176 🔗 searchSettings.json nlqConfiguration removal
The new getEnabledEntitySemantics method at RuleEngine.java:176 catches Exception broadly and silently returns an empty list. While this is defensive and fine for unit-test contexts, in production it could silently swallow real configuration errors (e.g., malformed settings JSON) that should surface. Consider catching only the specific exceptions that indicate missing/unavailable settings (e.g., EntityNotFoundException) and letting unexpected errors propagate.

Edge Case: Vector search pagination may silently under-return results

🔗 OpenSearchVectorService.search() pagination
In OpenSearchVectorService.search(), the from parameter for page offset is implemented by skipping parent groups in-memory after fetching from OpenSearch. The overFetch (from + size) * 2 may not fetch enough unique parents when threshold filtering removes many hits or when chunks cluster on few parents. The response silently returns fewer results than size without a total or hasMore indicator, making it impossible for the caller to distinguish between 'no more results' and 'under-fetched'. Consider adding a total count to VectorSearchResponse.

...and 2 more resolved from earlier reviews

🤖 Prompt for agents
Code Review: Unit test coverage expansion introduces a critical blocker: `createEntitiesIndex` has duplicate variable declarations and a malformed try block causing compilation failures, alongside an important issue where the vector search pagination loop may never terminate.

1. ⚠️ Bug: Vector search pagination loop may never terminate
   Files: openmetadata-service/src/main/java/org/openmetadata/service/search/vector/OpenSearchVectorService.java:154, openmetadata-service/src/main/java/org/openmetadata/service/search/vector/OpenSearchVectorService.java:172

   The new pagination loop in `searchVector` iterates `while (!exhausted && byParent.size() < requestedParents)`. When `totalHits` is unknown (-1, which happens when OpenSearch returns no `hits.total`), the exhaustion check at line 172 is `pageHitCount < overFetchSize`. If every page returns exactly `overFetchSize` raw hits but all of them score below `threshold` (so none are added to `byParent`), then:
   - `pageHitCount == overFetchSize` → `exhausted = false`
   - `byParent.size()` remains 0, never reaching `requestedParents`
   - The loop runs indefinitely, issuing unbounded requests to OpenSearch
   
   This scenario is possible when a high threshold is set and the index contains many low-scoring documents. Even when `totalHits >= 0`, if the index is very large it could loop for an excessive number of iterations before `rawOffset >= totalHits`.
   
   A maximum iteration cap (e.g., `MAX_PAGES = 10`) would prevent runaway loops in both cases.

   Suggested fix:
   // Add a max-page guard at the top of the method:
   int maxPages = 10; // safety cap
   int pageCount = 0;
   
   while (!exhausted && byParent.size() < requestedParents && pageCount < maxPages) {
       pageCount++;
       // ... existing loop body ...
   }

2. 🚨 Bug: createEntitiesIndex has duplicate variable + malformed try block
   Files: openmetadata-service/src/main/java/org/openmetadata/service/search/SearchRepository.java:858, openmetadata-service/src/main/java/org/openmetadata/service/search/SearchRepository.java:898, openmetadata-service/src/main/java/org/openmetadata/service/search/SearchRepository.java:859

   The `createEntitiesIndex` method has at least two compile-breaking issues introduced by this commit:
   
   1. **Duplicate local variable**: `Timer.Sample searchSample` is declared at line 858 (in the `if` block scope) and again at line 898 (inside the nested `try` block). Java does not allow a local variable in a nested scope to shadow a local variable from an enclosing scope within the same method — this is a compile error.
   
   2. **`try` without `catch`/`finally`**: The outer `try {` at line 859 has no matching `catch` or `finally` clause. The `} finally {` at line 905 belongs to the inner `try` at line 899, leaving the outer try structurally invalid.
   
   This appears to be a bad merge: the original code had a single `Timer.Sample searchSample` + `try/catch/finally` block. The new code added an outer `try` and moved `searchSample` earlier, but the old `searchSample` declaration and inner `try/finally` were also retained, creating overlapping broken structures.
   
   The fix is to remove the duplicate `Timer.Sample searchSample` at line 898 and the inner `try {` at line 899, keeping only the outer try-finally that wraps the entire operation.

   Suggested fix:
   Remove the duplicate variable and inner try block. The outer try-finally should wrap everything:
   
   // Remove line 898: Timer.Sample searchSample = ...
   // Remove line 899: try {
   // Remove lines 905-907: } finally { ... }
   // Add finally to the outer try at line 859:
   //   } finally {
   //     RequestLatencyContext.endSearchOperation(searchSample);
   //   }

Options

Auto-apply is off → Gitar will not commit updates to this branch.
Display: compact → Showing less information.

Comment with these commands to change:

Auto-apply Compact
gitar auto-apply:on         
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Gitar

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend safe to test Add this label to run secure Github workflows on PRs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants