Skip to content

UPSTREAM: <carry>: fix: skip unstarted handlers in RetrieveUserContainerEnvVars and ApplyCustomProperties - #409

Open
jira-autofix[bot] wants to merge 2 commits into
masterfrom
autofix/rhoaieng-76883
Open

UPSTREAM: <carry>: fix: skip unstarted handlers in RetrieveUserContainerEnvVars and ApplyCustomProperties#409
jira-autofix[bot] wants to merge 2 commits into
masterfrom
autofix/rhoaieng-76883

Conversation

@jira-autofix

@jira-autofix jira-autofix Bot commented Jul 15, 2026

Copy link
Copy Markdown

Summary

Fixes RHOAIENG-76883: Pipeline scheduling fails when MLflow handler initialization fails due to missing CA bundle.

Root cause: RetrieveUserContainerEnvVars and ApplyCustomProperties in dispatcher.go iterated all handlers unconditionally. When the MLflow handler's OnTaskStart fails (e.g., missing /dsp-custom-certs/dsp-ca.crt), it is not recorded in startedHandlers, but RetrieveUserContainerEnvVars still called it, causing a fatal error when trying to inject MLFLOW_RUN_ID from an uninitialized handler.

Fix: Added the same startedHandlers guard to RetrieveUserContainerEnvVars and ApplyCustomProperties that OnTaskEnd already uses. Handlers whose OnTaskStart failed are now skipped consistently across all dispatcher methods.

Additional change: Redacted env var values from the duplicate-key log message in RetrieveUserContainerEnvVars to prevent sensitive data exposure (CWE-532).

Files changed

  • backend/src/v2/common/plugins/dispatcher.go — Added startedHandlers guard + redacted log values
  • backend/src/v2/common/plugins/dispatcher_test.go — Added 4 test cases covering skip behavior for both methods

Test plan

  • Unit tests added for RetrieveUserContainerEnvVars skipping unstarted handlers (single and mixed)
  • Unit tests added for ApplyCustomProperties skipping unstarted handlers (single and mixed)
  • E2E validation with MLflow integration on a cluster with missing CA bundle

Summary by CodeRabbit

  • Bug Fixes

    • Prevented inactive task handlers from contributing environment variables or custom properties.
    • Improved duplicate environment-variable logging to identify the contributing handler.
  • Tests

    • Added coverage for tasks with inactive handlers and mixed active/inactive handler scenarios.

@openshift-ci-robot

openshift-ci-robot commented Jul 15, 2026

Copy link
Copy Markdown

@jira-autofix[bot]: This pull request references RHOAIENG-76883 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the bug to target the "5.0.0" version, but no target version was set.

Details

In response to this:

Summary

When a task plugin handler fails during OnTaskStart (e.g., MLflow handler cannot read CA bundle at /dsp-custom-certs/dsp-ca.crt), it is not recorded in startedHandlers. The OnTaskEnd method already checks startedHandlers and skips handlers that did not start successfully, but RetrieveUserContainerEnvVars and ApplyCustomProperties were missing this guard.

This caused a fatal error when RetrieveUserContainerEnvVars tried to retrieve env vars (like MLFLOW_RUN_ID) from handlers whose initialization had failed, blocking all pipelines when MLflow integration is enabled but the CA bundle is not available.

Changes

  • Added the same startedHandlers guard to RetrieveUserContainerEnvVars and ApplyCustomProperties that OnTaskEnd already uses
  • When startedHandlers is populated (after OnTaskStart runs), handlers not in the map are skipped with an info log
  • When startedHandlers is nil (OnTaskStart was never called), all handlers are still invoked for backward compatibility
  • Added four new test cases covering single-handler and mixed-handler scenarios for both methods

Test Plan

  • New unit tests for RetrieveUserContainerEnvVars skipping unstarted handlers
  • New unit tests for ApplyCustomProperties skipping unstarted handlers
  • Manual verification: deploy with MLflow integration enabled but CA bundle missing — pipeline should proceed without fatal error

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 openshift-eng/jira-lifecycle-plugin repository.

@openshift-ci
openshift-ci Bot requested review from HumairAK and mprahl July 15, 2026 11:49
@openshift-ci

openshift-ci Bot commented Jul 15, 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 mprahl 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

@coderabbitai

coderabbitai Bot commented Jul 15, 2026

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

The dispatcher skips environment-variable retrieval and custom-property application for handlers whose OnTaskStart failed. Test fakes record applied properties, and new tests cover single unstarted handlers and mixed started/unstarted handler sets.

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

🚥 Pre-merge checks | ✅ 10
✅ Passed checks (10 passed)
Check name Status Explanation
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.
Contribution Quality And Spam Detection ✅ Passed Only one mild templated-description signal; the change is issue-linked, code-specific, and has targeted tests. No second signal from SECURITY THEATER/CODE QUALITY.
No Hardcoded Secrets ✅ Passed Only change is a log redaction in dispatcher.go; no hardcoded secrets, credentialed URLs, or api_key/secret/token/password literals found. CWE-798/CWE-259 not triggered.
No Weak Cryptography ✅ Passed PASS: Diff only changes dispatcher guard/log text and tests; no MD5/SHA1/DES/RC4/ECB, custom crypto, or secret comparisons found (CWE-327/CWE-208).
No Injection Vectors ✅ Passed No CWE-89/78/94/502/79 pattern appears in the changed runtime code; the only runtime change redacts log output and uses trusted handler names.
No Privileged Containers ✅ Passed Only a Go log-message change landed; no manifests/Helm/Dockerfiles changed, and no privileged settings were introduced (CWE-250).
No Sensitive Data In Logs ✅ Passed PASS: dispatcher logs no secrets; the duplicate env-var message now omits values and only emits key/handler names, addressing CWE-532.
Title check ✅ Passed The title clearly names the main behavioral change: skipping unstarted handlers in both dispatcher methods.
Description check ✅ Passed The description includes the issue, root cause, fix, file list, and test plan, which covers the template's main required content.

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

@dsp-developers

Copy link
Copy Markdown

Commit Checker results:

**NOTE**: These are the results of the commit checker scans. 
If these are not commits from upstream kfp, then please ensure
you adhere to the commit checker formatting
commitchecker verson unknown
Validating 1 commits between 3a1866e3c7ce2d853e93d082255c511433773105...28c3686ba80b66385fff843b801931f796056747

UPSTREAM commit 28c3686 has invalid summary RHOAIENG-76883: Skip unstarted handlers in RetrieveUserContainerEnvVars and ApplyCustomProperties.

UPSTREAM commits are validated against the following regular expression:
  ^UPSTREAM: (revert: )?(([\w.-]+/[\w-.-]+)?: )?(\d+:|<carry>:|<drop>:)

UPSTREAM commit summaries should look like:

  UPSTREAM: <PR number|carry|drop>: description

UPSTREAM commits which revert previous UPSTREAM commits should look like:

  UPSTREAM: revert: <normal upstream format>

Examples of valid summaries:

  UPSTREAM: 12345: A kube fix
  UPSTREAM: <carry>: A carried kube change
  UPSTREAM: <drop>: A dropped kube change
  UPSTREAM: revert: 12345: A kube revert


@openshift-ci-robot

openshift-ci-robot commented Jul 15, 2026

Copy link
Copy Markdown

@jira-autofix[bot]: This pull request references RHOAIENG-76883 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the bug to target the "5.0.0" version, but no target version was set.

Details

In response to this:

Summary

When a task plugin handler fails during OnTaskStart (e.g., MLflow handler cannot read CA bundle at /dsp-custom-certs/dsp-ca.crt), it is not recorded in startedHandlers. The OnTaskEnd method already checks startedHandlers and skips handlers that did not start successfully, but RetrieveUserContainerEnvVars and ApplyCustomProperties were missing this guard.

This caused a fatal error when RetrieveUserContainerEnvVars tried to retrieve env vars (like MLFLOW_RUN_ID) from handlers whose initialization had failed, blocking all pipelines when MLflow integration is enabled but the CA bundle is not available.

Changes

  • Added the same startedHandlers guard to RetrieveUserContainerEnvVars and ApplyCustomProperties that OnTaskEnd already uses
  • When startedHandlers is populated (after OnTaskStart runs), handlers not in the map are skipped with an info log
  • When startedHandlers is nil (OnTaskStart was never called), all handlers are still invoked for backward compatibility
  • Added four new test cases covering single-handler and mixed-handler scenarios for both methods

Test Plan

  • New unit tests for RetrieveUserContainerEnvVars skipping unstarted handlers
  • New unit tests for ApplyCustomProperties skipping unstarted handlers
  • Manual verification: deploy with MLflow integration enabled but CA bundle missing — pipeline should proceed without fatal error

Summary by CodeRabbit

  • Bug Fixes
  • Improved task processing reliability by preventing downstream handler actions from running when a handler fails to start.
  • Environment variables are now collected only from successfully started handlers.
  • Custom properties are applied only to handlers that started successfully.
  • Tests
  • Added coverage for scenarios involving failed and mixed handler startup results.

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 openshift-eng/jira-lifecycle-plugin repository.

@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)
backend/src/v2/common/plugins/dispatcher_test.go (1)

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

Add a test for the startedHandlers == nil fallback. These cases only cover handlers that went through OnTaskStart; add one test that never calls OnTaskStart so RetrieveUserContainerEnvVars and ApplyCustomProperties still cover the backward-compatibility path.

🤖 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 `@backend/src/v2/common/plugins/dispatcher_test.go` around lines 300 - 381, Add
a test covering a newly constructed dispatcher whose startedHandlers state
remains nil because OnTaskStart is never called. Exercise both
RetrieveUserContainerEnvVars and ApplyCustomProperties, and assert they use the
backward-compatible behavior for the configured handler(s), including expected
environment variables and applied properties.
🤖 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 `@backend/src/v2/common/plugins/dispatcher_test.go`:
- Around line 300-381: Add a test covering a newly constructed dispatcher whose
startedHandlers state remains nil because OnTaskStart is never called. Exercise
both RetrieveUserContainerEnvVars and ApplyCustomProperties, and assert they use
the backward-compatible behavior for the configured handler(s), including
expected environment variables and applied properties.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Central YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Enterprise

Run ID: 21c7dbe9-834b-40ff-a38e-d2b5d2365d4e

📥 Commits

Reviewing files that changed from the base of the PR and between 3a1866e and 28c3686.

📒 Files selected for processing (2)
  • backend/src/v2/common/plugins/dispatcher.go
  • backend/src/v2/common/plugins/dispatcher_test.go

@dsp-developers

Copy link
Copy Markdown

A set of new images have been built to help with testing out this PR:
API Server: quay.io/opendatahub/ds-pipelines-api-server:pr-409
DSP DRIVER: quay.io/opendatahub/ds-pipelines-driver:pr-409
DSP LAUNCHER: quay.io/opendatahub/ds-pipelines-launcher:pr-409
Persistence Agent: quay.io/opendatahub/ds-pipelines-persistenceagent:pr-409
Scheduled Workflow Manager: quay.io/opendatahub/ds-pipelines-scheduledworkflow:pr-409
MLMD Server: quay.io/opendatahub/mlmd-grpc-server:latest
MLMD Envoy Proxy: registry.redhat.io/openshift-service-mesh/proxyv2-rhel8:2.3.9-2
UI: quay.io/opendatahub/ds-pipelines-frontend:pr-409
TESTS: quay.io/opendatahub/ds-pipelines-tests:pr-409

@dsp-developers

Copy link
Copy Markdown

An OCP cluster where you are logged in as cluster admin is required.

The Data Science Pipelines team recommends testing this using the Data Science Pipelines Operator. Check here for more information on using the DSPO.

To use and deploy a DSP stack with these images (assuming the DSPO is deployed), first save the following YAML to a file named dspa.pr-409.yaml:

apiVersion: datasciencepipelinesapplications.opendatahub.io/v1
kind: DataSciencePipelinesApplication
metadata:
  name: pr-409
spec:
  dspVersion: v2
  apiServer:
    image: "quay.io/opendatahub/ds-pipelines-api-server:pr-409"
    argoDriverImage: "quay.io/opendatahub/ds-pipelines-driver:pr-409"
    argoLauncherImage: "quay.io/opendatahub/ds-pipelines-launcher:pr-409"
  persistenceAgent:
    image: "quay.io/opendatahub/ds-pipelines-persistenceagent:pr-409"
  scheduledWorkflow:
    image: "quay.io/opendatahub/ds-pipelines-scheduledworkflow:pr-409"
  mlmd:  
    deploy: true  # Optional component
    grpc:
      image: "quay.io/opendatahub/mlmd-grpc-server:latest"
    envoy:
      image: "registry.redhat.io/openshift-service-mesh/proxyv2-rhel8:2.3.9-2"
  mlpipelineUI:
    deploy: true  # Optional component 
    image: "quay.io/opendatahub/ds-pipelines-frontend:pr-409"
  objectStorage:
    minio:
      deploy: true
      image: 'quay.io/opendatahub/minio:RELEASE.2019-08-14T20-37-41Z-license-compliance'

Then run the following:

cd $(mktemp -d)
git clone git@github.com:opendatahub-io/data-science-pipelines.git
cd data-science-pipelines/
git fetch origin pull/409/head
git checkout -b pullrequest 28c3686ba80b66385fff843b801931f796056747
oc apply -f dspa.pr-409.yaml

More instructions here on how to deploy and test a Data Science Pipelines Application.

jira-autofix Bot pushed a commit that referenced this pull request Jul 15, 2026
Addresses review feedback on PR #409:
- Removes raw env var values from duplicate-key log message in
  RetrieveUserContainerEnvVars to prevent sensitive data exposure
  (CWE-532). Now logs only the key name and handler name.

RHOAIENG-76883

Assisted-by: Claude claude-opus-4-6 <noreply@anthropic.com>
@jira-autofix jira-autofix Bot changed the title RHOAIENG-76883: Skip unstarted handlers in RetrieveUserContainerEnvVars and ApplyCustomProperties UPSTREAM: <carry>: fix: skip unstarted handlers in RetrieveUserContainerEnvVars and ApplyCustomProperties Jul 15, 2026
@dsp-developers

Copy link
Copy Markdown

Commit Checker results:

**NOTE**: These are the results of the commit checker scans. 
If these are not commits from upstream kfp, then please ensure
you adhere to the commit checker formatting
commitchecker verson unknown
Validating 2 commits between 3a1866e3c7ce2d853e93d082255c511433773105...7008f8695bee6e1eac489386ed647ef52b55e68c

UPSTREAM commit 28c3686 has invalid summary RHOAIENG-76883: Skip unstarted handlers in RetrieveUserContainerEnvVars and ApplyCustomProperties.

UPSTREAM commits are validated against the following regular expression:
  ^UPSTREAM: (revert: )?(([\w.-]+/[\w-.-]+)?: )?(\d+:|<carry>:|<drop>:)

UPSTREAM commit summaries should look like:

  UPSTREAM: <PR number|carry|drop>: description

UPSTREAM commits which revert previous UPSTREAM commits should look like:

  UPSTREAM: revert: <normal upstream format>

Examples of valid summaries:

  UPSTREAM: 12345: A kube fix
  UPSTREAM: <carry>: A carried kube change
  UPSTREAM: <drop>: A dropped kube change
  UPSTREAM: revert: 12345: A kube revert


@dsp-developers

Copy link
Copy Markdown

Change to PR detected. A new PR build was completed.
A set of new images have been built to help with testing out this PR:
API Server: quay.io/opendatahub/ds-pipelines-api-server:pr-409
DSP DRIVER: quay.io/opendatahub/ds-pipelines-driver:pr-409
DSP LAUNCHER: quay.io/opendatahub/ds-pipelines-launcher:pr-409
Persistence Agent: quay.io/opendatahub/ds-pipelines-persistenceagent:pr-409
Scheduled Workflow Manager: quay.io/opendatahub/ds-pipelines-scheduledworkflow:pr-409
MLMD Server: quay.io/opendatahub/mlmd-grpc-server:latest
MLMD Envoy Proxy: registry.redhat.io/openshift-service-mesh/proxyv2-rhel8:2.3.9-2
UI: quay.io/opendatahub/ds-pipelines-frontend:pr-409
TESTS: quay.io/opendatahub/ds-pipelines-tests:pr-409

aipcc-bot added 2 commits July 15, 2026 14:47
…nerEnvVars and ApplyCustomProperties

When a task plugin handler fails during OnTaskStart (e.g., MLflow handler
cannot read CA bundle), it is not recorded in startedHandlers. The
OnTaskEnd method already checks startedHandlers and skips handlers that
did not start successfully, but RetrieveUserContainerEnvVars and
ApplyCustomProperties were missing this guard. This caused a fatal error
when RetrieveUserContainerEnvVars tried to retrieve env vars (like
MLFLOW_RUN_ID) from handlers whose initialization had failed, and
ApplyCustomProperties would do unnecessary work on unstarted handlers.

Add the same startedHandlers check to RetrieveUserContainerEnvVars and
ApplyCustomProperties that OnTaskEnd already uses, so handlers that
failed to start are skipped consistently across all dispatcher methods.
Add tests covering the single unstarted handler case and the mixed
(started + unstarted) handler case for both methods.

RHOAIENG-76883

Assisted-by: Claude claude-opus-4-6 <noreply@anthropic.com>
Addresses review feedback on PR #409:
- Removes raw env var values from duplicate-key log message in
  RetrieveUserContainerEnvVars to prevent sensitive data exposure
  (CWE-532). Now logs only the key name and handler name.

RHOAIENG-76883

Assisted-by: Claude claude-opus-4-6 <noreply@anthropic.com>
@jira-autofix
jira-autofix Bot force-pushed the autofix/rhoaieng-76883 branch from 7008f86 to df2cd81 Compare July 15, 2026 14:50
@dsp-developers

Copy link
Copy Markdown

Commit Checker results:

**NOTE**: These are the results of the commit checker scans. 
If these are not commits from upstream kfp, then please ensure
you adhere to the commit checker formatting
commitchecker verson unknown
Validating 0 commits between 775c02b05f0ea37d6791f75ef95961f6b5c83a7e...df2cd81ca7704a8d5209083a65710e58b414f447

@dsp-developers

Copy link
Copy Markdown

Change to PR detected. A new PR build was completed.
A set of new images have been built to help with testing out this PR:
API Server: quay.io/opendatahub/ds-pipelines-api-server:pr-409
DSP DRIVER: quay.io/opendatahub/ds-pipelines-driver:pr-409
DSP LAUNCHER: quay.io/opendatahub/ds-pipelines-launcher:pr-409
Persistence Agent: quay.io/opendatahub/ds-pipelines-persistenceagent:pr-409
Scheduled Workflow Manager: quay.io/opendatahub/ds-pipelines-scheduledworkflow:pr-409
MLMD Server: quay.io/opendatahub/mlmd-grpc-server:latest
MLMD Envoy Proxy: registry.redhat.io/openshift-service-mesh/proxyv2-rhel8:2.3.9-2
UI: quay.io/opendatahub/ds-pipelines-frontend:pr-409
TESTS: quay.io/opendatahub/ds-pipelines-tests:pr-409

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