Skip to content

OLS-3654 Fix empty top-level diagnosis CRD validation failure#344

Open
vimalk78 wants to merge 1 commit into
openshift:mainfrom
vimalk78:ols-3654-empty-diagnosis
Open

OLS-3654 Fix empty top-level diagnosis CRD validation failure#344
vimalk78 wants to merge 1 commit into
openshift:mainfrom
vimalk78:ols-3654-empty-diagnosis

Conversation

@vimalk78

@vimalk78 vimalk78 commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Adds failing tests that reproduce OLS-3654: when the analysis agent returns actionRequired: true with per-option diagnoses but an empty top-level diagnosis (summary="", rootCause="", confidence="Low"), the non-nil Diagnosis pointer causes the empty struct to be written to the AnalysisResult status, which fails CRD MinLength=1 validation
  • Fix not yet implemented — tests document the expected behavior

Test plan

  • TestCreateAnalysisResult_EmptyTopLevelDiagnosis — verifies createAnalysisResult does not write empty diagnosis fields to status
  • TestSandboxAgentCaller_Analyze_EmptyTopLevelDiagnosis — verifies Analyze() normalizes empty diagnosis to nil

🤖 Generated with Claude Code

@openshift-ci openshift-ci Bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jul 17, 2026
@openshift-ci

openshift-ci Bot commented Jul 17, 2026

Copy link
Copy Markdown

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@openshift-ci

openshift-ci Bot commented Jul 17, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign harche for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@vimalk78
vimalk78 force-pushed the ols-3654-empty-diagnosis branch from 371eb58 to d1b9129 Compare July 17, 2026 12:08
@coderabbitai

coderabbitai Bot commented Jul 17, 2026

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 990f1705-3746-42a0-965b-4cfffd918fce

📥 Commits

Reviewing files that changed from the base of the PR and between d1b9129 and ad29534.

📒 Files selected for processing (4)
  • controller/agenticrun/results.go
  • controller/agenticrun/results_test.go
  • controller/agenticrun/sandbox_agent.go
  • controller/agenticrun/sandbox_agent_test.go
🔗 Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

  • openshift/lightspeed-agentic-sandbox (manual)
🚧 Files skipped from review as they are similar to previous changes (3)
  • controller/agenticrun/sandbox_agent.go
  • controller/agenticrun/results_test.go
  • controller/agenticrun/sandbox_agent_test.go

📝 Walkthrough

Summary by CodeRabbit

  • Bug Fixes
    • Incomplete top-level diagnosis information is now ignored instead of being saved as a diagnosis.
    • Valid diagnosis details associated with individual remediation options are preserved.
    • Prevents empty summaries or root causes from appearing in analysis results.

Walkthrough

The change filters incomplete top-level diagnoses during sandbox analysis and status construction. Regression tests verify that empty top-level diagnosis fields are omitted while per-option diagnoses remain preserved.

Changes

Diagnosis validation and persistence

Layer / File(s) Summary
Sanitize incomplete analysis responses
controller/agenticrun/sandbox_agent.go, controller/agenticrun/sandbox_agent_test.go
Top-level diagnoses missing Summary or RootCause are cleared after parsing, while option-level diagnoses remain populated and tested.
Persist only complete diagnoses
controller/agenticrun/results.go, controller/agenticrun/results_test.go
Status assignment now requires non-empty Summary and RootCause; regression tests cover multiple incomplete top-level diagnosis cases and preserved option-level diagnoses.

Sequence Diagram(s)

sequenceDiagram
  participant SandboxAgentCaller
  participant AgenticRunReconciler
  participant AnalysisResultStatus
  SandboxAgentCaller->>SandboxAgentCaller: parse and clear incomplete top-level Diagnosis
  SandboxAgentCaller->>AgenticRunReconciler: return analysis output with option diagnoses
  AgenticRunReconciler->>AnalysisResultStatus: persist complete top-level Diagnosis
  AgenticRunReconciler->>AnalysisResultStatus: preserve option-level diagnoses
Loading
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly matches the main change: handling empty top-level diagnosis data that triggers CRD validation failure.
Description check ✅ Passed The description directly describes the same diagnosis-validation issue and the tests added around it.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.

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

@vimalk78
vimalk78 marked this pull request as ready for review July 17, 2026 12:10
@openshift-ci
openshift-ci Bot requested review from blublinsky and harche July 17, 2026 12:10
@vimalk78 vimalk78 changed the title WIP: OLS-3654 Fix empty top-level diagnosis CRD validation failure OLS-3654 Fix empty top-level diagnosis CRD validation failure Jul 17, 2026
@openshift-ci openshift-ci Bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jul 17, 2026

@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.

Actionable comments posted: 2

🤖 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.

Inline comments:
In `@controller/agenticrun/sandbox_agent_test.go`:
- Around line 437-442: The incomplete-diagnosis tests cover only when both
required fields are empty; extend the cases around the sandbox diagnosis
assertion in controller/agenticrun/sandbox_agent_test.go:437-442 to cover
Summary-only and RootCause-only omissions, asserting the returned diagnosis is
nil. Add the corresponding one-sided empty-field cases around the persisted
status diagnosis assertions in controller/agenticrun/results_test.go:249-256,
asserting the status diagnosis is unset.

In `@controller/agenticrun/sandbox_agent.go`:
- Around line 109-112: Move the incomplete top-level diagnosis sanitization
block before the missing-diagnosis validation in the surrounding
response-handling flow. Ensure an incomplete diagnosis is set to nil before the
check that logs or handles missing diagnoses, so actionRequired=false responses
trigger the intended missing-diagnosis behavior; preserve the existing
per-option diagnosis handling.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 888866e8-0efd-4aa9-bd03-e8aac7be5c47

📥 Commits

Reviewing files that changed from the base of the PR and between 8be7766 and d1b9129.

📒 Files selected for processing (4)
  • controller/agenticrun/results.go
  • controller/agenticrun/results_test.go
  • controller/agenticrun/sandbox_agent.go
  • controller/agenticrun/sandbox_agent_test.go
🔗 Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

  • openshift/lightspeed-agentic-sandbox (manual)

Comment thread controller/agenticrun/sandbox_agent_test.go Outdated
Comment thread controller/agenticrun/sandbox_agent.go
When the agent returns actionRequired=true with per-option diagnoses
but an empty top-level diagnosis (summary="", rootCause="",
confidence="Low"), the non-nil Diagnosis pointer causes the empty
struct to be written to the AnalysisResult status. The CRD's
MinLength=1 on summary and rootCause rejects the status patch.

Fix: normalize empty diagnosis to nil in the parsing layer, and guard
the assignment in createAnalysisResult to skip empty fields.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Vimal Kumar <vimal78@gmail.com>
@vimalk78
vimalk78 force-pushed the ols-3654-empty-diagnosis branch from d1b9129 to ad29534 Compare July 17, 2026 12:17
@openshift-ci

openshift-ci Bot commented Jul 17, 2026

Copy link
Copy Markdown

@vimalk78: all tests passed!

Full PR test history. Your PR dashboard.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

@vimalk78

Copy link
Copy Markdown
Contributor Author

@coderabbitai approve

@coderabbitai

coderabbitai Bot commented Jul 17, 2026

Copy link
Copy Markdown
✅ Action performed

Comments resolved and changes approved.

@blublinsky blublinsky 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.

should-fix: incomplete top-level diagnosis should also reject empty/missing confidence

OLS-3654 correctly drops a top-level Diagnosis when summary or rootCause is empty, which avoids CRD MinLength=1 failures on those fields. The CRD still requires all three:

required: [confidence, rootCause, summary]
# confidence enum: Low | Medium | High

With a payload like:

{
  "summary": "PostgresqlTooManyConnections firing",
  "rootCause": "pool exhaustion",
  "confidence": ""
}

(or confidence omitted → Go zero value), both guards still treat the diagnosis as complete:

  • sandbox_agent.go: only checks Summary == "" || RootCause == ""
  • results.go: only requires Summary != "" && RootCause != ""

confidence is omitempty, so it is dropped from the status JSON and the API rejects the update for missing required confidence — same status-patch failure mode as OLS-3654.

Suggest treating the diagnosis as complete only when Summary, RootCause, and a valid Confidence (Low/Medium/High) are set, in both places, plus a table-driven test case for empty/missing confidence. A small shared helper would keep the parse-path and write-path checks aligned.

Happy to take this as a follow-up if you prefer to land the empty summary/rootCause fix first.

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