Skip to content

chore(backend): Consolidate v2 placeholder resolution into shared utility. Fixes #12949#13027

Open
khushiiagrawal wants to merge 6 commits intokubeflow:masterfrom
khushiiagrawal:chore/issue-12949
Open

chore(backend): Consolidate v2 placeholder resolution into shared utility. Fixes #12949#13027
khushiiagrawal wants to merge 6 commits intokubeflow:masterfrom
khushiiagrawal:chore/issue-12949

Conversation

@khushiiagrawal
Copy link
Copy Markdown
Contributor

Description of your changes:

This PR consolidates duplicate placeholder resolution and type stringification logic that existed in both the driver and launcher into a shared utility package, addressing technical debt from PR #12598.

Fixes #12949

What changed:

  • Created new backend/src/v2/placeholder/ package with:

    • PbValueToString() - canonical structpb.Value to string conversion
    • ResolveInputParameterPlaceholders() - shared input parameter placeholder resolution
    • InputParameterRe - exported regex pattern for placeholder matching
  • Updated backend/src/v2/driver/util.go:

    • Removed duplicate pbValueToString, resolveSinglePlaceholder, resolveInputParameterPlaceholders functions
    • Now calls shared package for common logic
    • Kept driver-specific logic (IfPresent expansion, output placeholder handling)
  • Updated backend/src/v2/component/launcher_v2.go:

    • Replaced 25-line inline type conversion switch with single call to shared function
    • Fixed latent bug where null values weren't handled

Why:

  • Eliminates code duplication between driver and launcher
  • Prevents behavior drift across layers
  • Centralizes type conversion and placeholder resolution for easier maintenance
  • All existing tests pass with no behavioral changes

Checklist:

Copilot AI review requested due to automatic review settings March 13, 2026 19:23
@google-oss-prow
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 Kubernetes 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

@google-oss-prow
Copy link
Copy Markdown

Hi @khushiiagrawal. Thanks for your PR.

I'm waiting for a kubeflow member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

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/test-infra repository.

@khushiiagrawal
Copy link
Copy Markdown
Contributor Author

@droctothorpe @hbelmiro PTAL. thanks.

Copy link
Copy Markdown
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 centralizes v2 input-parameter placeholder substitution and structpb.Value → string conversion into a new shared backend/src/v2/placeholder package, then updates both the driver and launcher to use that canonical implementation (including proper handling of null values).

Changes:

  • Added backend/src/v2/placeholder with shared utilities: PbValueToString, ResolveInputParameterPlaceholders, and InputParameterRe.
  • Refactored backend/src/v2/driver/util.go to call the shared placeholder resolver instead of maintaining a duplicate implementation.
  • Refactored backend/src/v2/component/launcher_v2.go to use PbValueToString, fixing prior null handling for input parameters.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
backend/src/v2/placeholder/placeholder.go New shared placeholder/type-stringification utility used by both driver and launcher.
backend/src/v2/placeholder/placeholder_test.go Unit tests covering value stringification and placeholder substitution scenarios.
backend/src/v2/driver/util.go Removes duplicated placeholder logic and routes resolution through the shared package.
backend/src/v2/component/launcher_v2.go Replaces inline structpb.Value kind switching with PbValueToString (incl. null).

Comment on lines +31 to +33
// InputParameterRe matches the complete {{$.inputs.parameters['name']}}
// placeholder including the surrounding double braces.
var InputParameterRe = regexp.MustCompile(`\{\{\$\.inputs\.parameters\['(.+?)']}}`)
…ers and update related functions

Signed-off-by: khushiiagrawal <khushisaritaagrawal@gmail.com>
Signed-off-by: khushiiagrawal <khushisaritaagrawal@gmail.com>
@zazulam zazulam force-pushed the chore/issue-12949 branch from 3db5039 to 0e79421 Compare March 17, 2026 19:02
khushiiagrawal and others added 3 commits March 20, 2026 00:30
… normalization utility

Signed-off-by: khushiiagrawal <khushisaritaagrawal@gmail.com>
Signed-off-by: Khushi Agrawal <149886195+khushiiagrawal@users.noreply.github.com>
@hbelmiro
Copy link
Copy Markdown
Contributor

hbelmiro commented Apr 7, 2026

@khushiiagrawal can you please rebase?

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

chore(backend): Consolidate v2 placeholder resolution into shared utility

3 participants