Skip to content

add(RHIDP-15096): add flag skip_metadata_assert to skip values assertion logic from ES histroy data - #175

Merged
jhutar merged 1 commit into
redhat-performance:mainfrom
shashankkestwal:chore/RHIDP-15096
Jul 15, 2026
Merged

add(RHIDP-15096): add flag skip_metadata_assert to skip values assertion logic from ES histroy data#175
jhutar merged 1 commit into
redhat-performance:mainfrom
shashankkestwal:chore/RHIDP-15096

Conversation

@shashankkestwal

@shashankkestwal shashankkestwal commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

No description provided.

@coderabbitai

coderabbitai Bot commented Jul 6, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Enterprise

Run ID: 1f6778c7-211b-4763-9acb-df3ca7951331

📥 Commits

Reviewing files that changed from the base of the PR and between b43a5f4 and d09214d.

📒 Files selected for processing (6)
  • core/opl/investigator/README.md
  • core/opl/investigator/config.py
  • core/opl/investigator/elasticsearch_loader.py
  • core/opl/investigator/sample_config.yaml
  • core/opl/pass_or_fail.py
  • core/opl/status_data.py
🚧 Files skipped from review as they are similar to previous changes (6)
  • core/opl/investigator/sample_config.yaml
  • core/opl/investigator/README.md
  • core/opl/investigator/config.py
  • core/opl/status_data.py
  • core/opl/pass_or_fail.py
  • core/opl/investigator/elasticsearch_loader.py

📝 Walkthrough

Summary by CodeRabbit

  • New Features

    • Added an optional Elasticsearch history setting to allow historical documents without status metadata fields.
    • Comparisons continue using only the configured metric paths.
  • Documentation

    • Documented the new setting, its default behavior, and configuration example.
    • Added guidance for enabling it when metadata fields are unavailable.

Walkthrough

This PR adds an optional skip_metadata_assert boolean that propagates from YAML configuration through Elasticsearch history loading into StatusData, where it conditionally skips required metadata key assertions.

Changes

skip_metadata_assert flag propagation

Layer / File(s) Summary
StatusData conditional metadata assertions
core/opl/status_data.py
StatusData.__init__ gains skip_metadata_assert and makes the name, started, ended, and result checks conditional on it.
Config loading and sample config for skip_metadata_assert
core/opl/investigator/config.py, core/opl/investigator/sample_config.yaml
load_config() reads history.skip_metadata_assert into conf.history_es_skip_metadata_assert; the sample config documents the new option.
Loader and CLI wiring of skip_metadata_assert
core/opl/investigator/elasticsearch_loader.py, core/opl/pass_or_fail.py
The Elasticsearch loader reads the flag from kwargs and passes it into StatusData; pass_or_fail.doit forwards args.history_es_skip_metadata_assert to the loader.
Documentation of skip_metadata_assert
core/opl/investigator/README.md
The README describes the new Elasticsearch history setting, its default, and the effect on metadata validation.

Estimated code review effort: 2 (Simple) | ~10 minutes

Sequence Diagram(s)

sequenceDiagram
  participant PassOrFail as pass_or_fail.doit
  participant Loader as elasticsearch_loader.load
  participant StatusData as StatusData.__init__

  PassOrFail->>Loader: Pass skip_metadata_assert from args
  Loader->>Loader: Read skip_metadata_assert from kwargs
  loop each Elasticsearch hit
    Loader->>StatusData: Construct with skip_metadata_assert
    alt skip_metadata_assert is false
      StatusData->>StatusData: Assert required metadata keys
    else skip_metadata_assert is true
      StatusData->>StatusData: Skip metadata assertions
    end
  end
Loading
🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ❓ Inconclusive No pull request description was provided, so there is no meaningful description to assess. Add a brief description explaining that the flag skips Elasticsearch metadata assertions for historical data.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the new skip_metadata_assert flag for Elasticsearch history validation.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@shashankkestwal
shashankkestwal marked this pull request as ready for review July 7, 2026 13:51

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
core/opl/status_data.py (1)

28-28: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Consider adding a test for the new skip_metadata_assert bypass path.

Logic is correct, but there's no test verifying that assertions are actually skipped when skip_metadata_assert=True and still enforced by default. This guards a validation path that other code (elasticsearch_loader) now relies on being correctly bypassable.

As per path instructions, focusing on maintainability impact of untested new behavior.

Also applies to: 46-50

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@core/opl/status_data.py` at line 28, Add tests for the new
skip_metadata_assert bypass in StatusData.__init__ to cover both behaviors: when
skip_metadata_assert=True, metadata validation assertions should be skipped, and
when omitted or false, the existing assertions should still run. Update or add a
focused test around StatusData and any caller path used by elasticsearch_loader
so the bypass is exercised through the new parameter and the default enforcement
remains covered.

Source: Path instructions

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@core/opl/status_data.py`:
- Line 28: Add tests for the new skip_metadata_assert bypass in
StatusData.__init__ to cover both behaviors: when skip_metadata_assert=True,
metadata validation assertions should be skipped, and when omitted or false, the
existing assertions should still run. Update or add a focused test around
StatusData and any caller path used by elasticsearch_loader so the bypass is
exercised through the new parameter and the default enforcement remains covered.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Enterprise

Run ID: 361af50e-a4ba-4bbd-9fc0-3642888d4281

📥 Commits

Reviewing files that changed from the base of the PR and between 29bdf09 and fdb2216.

📒 Files selected for processing (6)
  • core/opl/investigator/README.md
  • core/opl/investigator/config.py
  • core/opl/investigator/elasticsearch_loader.py
  • core/opl/investigator/sample_config.yaml
  • core/opl/pass_or_fail.py
  • core/opl/status_data.py

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
core/opl/investigator/elasticsearch_loader.py (1)

42-45: 🎯 Functional Correctness | 🔴 Critical | ⚡ Quick win

PR objective not met: KeyError on missing parameters still present.

The PR summary states this PR fixes the KeyError when an Elasticsearch document lacks a parameters field, but line 44 still accesses item['_source']['parameters'] directly in the if 'run' in item['_source']['parameters'] condition. If parameters is absent from item['_source'], this raises KeyError before the ternary can evaluate to None.

The id field on the same line uses the safe pattern (if 'id' in item['_source']), but parameters does not follow the same approach.

🐛 Proposed fix using `.get()` for `parameters`
         logging.debug(
-            f"Loading data from document ID {item['_id']} with field id={item['_source']['id'] if 'id' in item['_source'] else None} or parameters.run={item['_source']['parameters']['run'] if 'run' in item['_source']['parameters'] else None}"
+            f"Loading data from document ID {item['_id']} with field id={item['_source'].get('id')} or parameters.run={item['_source'].get('parameters', {}).get('run')}"
         )
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@core/opl/investigator/elasticsearch_loader.py` around lines 42 - 45, The
Elasticsearch loader still raises KeyError when `parameters` is missing because
`elasticsearch_loader.py` in the hit-processing loop accesses
`item['_source']['parameters']` directly in the debug log. Update the logging
expression in the `for item in response["hits"]["hits"]` block to use the same
safe access pattern as the `id` field, such as retrieving `parameters` via
`.get()` before checking for `run`, so the message can fall back to None when
`parameters` is absent.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@core/opl/investigator/elasticsearch_loader.py`:
- Around line 42-45: The Elasticsearch loader still raises KeyError when
`parameters` is missing because `elasticsearch_loader.py` in the hit-processing
loop accesses `item['_source']['parameters']` directly in the debug log. Update
the logging expression in the `for item in response["hits"]["hits"]` block to
use the same safe access pattern as the `id` field, such as retrieving
`parameters` via `.get()` before checking for `run`, so the message can fall
back to None when `parameters` is absent.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Enterprise

Run ID: d4cdf129-7112-4b86-9819-7c4daaffd086

📥 Commits

Reviewing files that changed from the base of the PR and between fdb2216 and b43a5f4.

📒 Files selected for processing (6)
  • core/opl/investigator/README.md
  • core/opl/investigator/config.py
  • core/opl/investigator/elasticsearch_loader.py
  • core/opl/investigator/sample_config.yaml
  • core/opl/pass_or_fail.py
  • core/opl/status_data.py
✅ Files skipped from review due to trivial changes (2)
  • core/opl/investigator/README.md
  • core/opl/investigator/sample_config.yaml
🚧 Files skipped from review as they are similar to previous changes (3)
  • core/opl/pass_or_fail.py
  • core/opl/investigator/config.py
  • core/opl/status_data.py

@shashankkestwal shashankkestwal changed the title fix: handle missing 'parameters' key in elasticsearch_loader add(RHIDP-15096): add flag bypass_es_assert to bypass values assertion logic from ES histroy data Jul 8, 2026
@shashankkestwal shashankkestwal changed the title add(RHIDP-15096): add flag bypass_es_assert to bypass values assertion logic from ES histroy data add(RHIDP-15096): add flag skip_metadata_assert to skip values assertion logic from ES histroy data Jul 8, 2026
@shashankkestwal

Copy link
Copy Markdown
Contributor Author

add option flag 'skip_metadata_assert' to skip historical field validation

Introduce a configurable flag to bypass validation of
historical OpenSearch document fields when performing result evaluation.
This enables projects using custom Elasticsearch indexes, where the asserted fields are unavailable, to run pass/fail checks without requiring a fully populated historical dataset with certain keys.

The existing behaviour remains unchanged unless the new flag is explicitly enabled.

…n logic from ES histroy data

Signed-off-by: skestwal <skestwal@redhat.com>

rh-pre-commit.version: 2.3.2
rh-pre-commit.check-secrets: ENABLED

@jhutar jhutar left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks perfectly safe, thank you!

@jhutar
jhutar merged commit af14f1e into redhat-performance:main Jul 15, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants