Skip to content

fix(trainer): validate non-empty schema and table in DataCacheInitializer storage_uri - #993

Open
blade0g wants to merge 1 commit into
kubeflow:mainfrom
blade0g:fix-datacache-empty-schema
Open

blade0g wants to merge 1 commit into
kubeflow:mainfrom
blade0g:fix-datacache-empty-schema

Conversation

@blade0g

@blade0g blade0g commented Nov 27, 2026 •

Copy link
Copy Markdown

Right now, DataCacheInitializer only checks if the URI splits into 2 parts after cache://, but it doesn't verify if the schema or table names are actually filled in.

Because of this, invalid inputs like cache://schema/, cache:///table, or cache:/// slip through without an error on the client side, only to fail later once the job runs on the cluster.

This PR adds a quick check (not all(parts)) to make sure neither the schema nor table name is empty, catching this early with a clean ValueError. Also added regression test cases in types_test.py covering these cases.

How was this patch tested?
Added new unit test cases covering empty schema, empty table, and both empty to types_test.py.
Ran pytest locally (all tests passing).
Ran ruff check and ruff format to keep styling clean.
Thanks for taking a look! Happy to address any feedback or suggestions.

Closes #881

Summary by CodeRabbit

  • Bug Fixes
    • Cache URIs with missing schema or table names are now rejected, preventing invalid cache locations from being accepted.

…izer storage_uri

DataCacheInitializer.__post_init__ validated that storage_uri contained two components after the 'cache://' scheme, but allowed either component to be empty (e.g. 'cache://schema/', 'cache:///table', 'cache:///').

This ensures both schema and table components are non-empty strings, and adds regression test cases for empty schema, empty table, and both.

Closes kubeflow#881

Signed-off-by: pratik <kattipratik78@gmail.com>
@google-oss-prow

Copy link
Copy Markdown
Contributor

[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 kramaranya 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

@github-actions

Copy link
Copy Markdown
Contributor

🎉 Welcome to the Kubeflow SDK! 🎉

Thanks for opening your first PR! We're happy to have you as part of our community 🚀

Here's what happens next:

  • If you haven't already, please check out our Contributing Guide for repo-specific guidelines and the Kubeflow Contributor Guide for general community standards
  • Our team will review your PR soon! cc @kubeflow/kubeflow-sdk-team

Join the community:

Feel free to ask questions in the comments if you need any help or clarification!
Thanks again for contributing to Kubeflow! 🙏

@coderabbitai

coderabbitai Bot commented Nov 27, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

DataCacheInitializer now rejects cache URIs with an empty schema or table name. Regression tests cover three malformed URIs.

Changes: Cache URI validation

Layer / File(s) Summary
Validate cache URI components
kubeflow/trainer/types/types.py, kubeflow/trainer/types/types_test.py
DataCacheInitializer now rejects URIs when either path component is empty. Tests expect ValueError for cache:///test_table, cache://test_schema/, and cache:///.

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

Change: Bug fix · Severity of issue fixed: Medium

Suggested reviewers: akshaychitneni

Merge Risk: Minimal · up to 6c4d0

This change makes the SDK reject cache URIs with an empty schema or table name at construction, as the linked issue requests. Valid URIs are still accepted. No concrete merge-blocking risk was found.

Security architecture risk: Minimal · up to 6c4d0

Cache URIs with a missing schema or table now fail when the initializer is created. Valid URIs behave as before, and the change does not grant new access or alter how jobs are deployed.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The new condition only rejects inputs on a path that previously accepted them. It does not make any previously rejected URI reachable through this constructor.

Trust Boundaries and Controls

  • observed — The added check enforces URI structure locally. It does not check whether the caller is authorized to access the named schema or table.
Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title states the main change: DataCacheInitializer now validates that the schema and table in storage_uri are non-empty. The raw summary and objectives confirm this matches the code change (a stri…
Linked Issues check Passed Directly linked issue #881 requires a ValueError when the schema or table name in storage_uri is empty, and valid cache://schema/table URIs must still be accepted. At the reviewed head, DataCacheIniti…
Out of Scope Changes check Passed The changes are limited to the DataCacheInitializer URI validation in kubeflow/trainer/types/types.py and new parametrized test cases in kubeflow/trainer/types/types_test.py. Both changes directly imp…
Full details: Title check

Explanation

The title states the main change: DataCacheInitializer now validates that the schema and table in storage_uri are non-empty. The raw summary and objectives confirm this matches the code change (a stricter check in post_init) and the added regression tests. The conventional-commit prefix 'fix(trainer)' fits the change scope. The title is specific and concise.

Full details: Linked Issues check

Explanation

Directly linked issue #881 requires a ValueError when the schema or table name in storage_uri is empty, and valid cache://schema/table URIs must still be accepted. At the reviewed head, DataCacheInitializer.post_init in kubeflow/trainer/types/types.py splits the path after 'cache://' and raises ValueError when len(parts) != 2 or not all(parts). This rejects cache://schema/, cache:///table, and cache:///. Valid URIs still pass the check. The issue also requires regression tests in kubeflow/trainer/types/types_test.py. At head, test_data_cache_initializer contains three FAILED cases with expected_error=ValueError for these three URIs, and the existing valid case cache://test_schema/test_table is unchanged. The PR description reports a local pytest run; that run is not independently verified here.

Full details: Out of Scope Changes check

Explanation

The changes are limited to the DataCacheInitializer URI validation in kubeflow/trainer/types/types.py and new parametrized test cases in kubeflow/trainer/types/types_test.py. Both changes directly implement issue #881. No unrelated files or behavior changes were identified in the inspected evidence. The whole-PR diff tool was unavailable, so the review relied on the reviewed head file contents and the PR summary for the scope of changes.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

  • Source mode: Auto
  • Repository: kubeflow/sdk
  • Branch: main
  • File: .coderabbit.yaml
  • Commit: 6f3ef0e
  • Layers: Repository YAML
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 1b9e68c5-ce90-4218-b247-375739a5cd42
Commits

Reviewing files that changed from the base of the PR and between 6f3ef0e and 6c4d0c1.

Files selected for processing: 2

  • kubeflow/trainer/types/types.py
  • kubeflow/trainer/types/types_test.py

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

This branch has not been deployed

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

Labels

Projects

Status: Ready to Merge

Development

Successfully merging this pull request may close these issues.

fix(trainer): DataCacheInitializer accepts empty schema or table name in storage_uri

1 participant