Skip to content

fix: replace bare except: with except Exception: in SDK#13084

Open
harshadkhetpal wants to merge 3 commits intokubeflow:masterfrom
harshadkhetpal:fix/bare-except-sdk
Open

fix: replace bare except: with except Exception: in SDK#13084
harshadkhetpal wants to merge 3 commits intokubeflow:masterfrom
harshadkhetpal:fix/bare-except-sdk

Conversation

@harshadkhetpal
Copy link

Summary

Replace bare except: clauses with except Exception: across three SDK files to comply with PEP 8 E722.

Bare except clauses catch everything including KeyboardInterrupt and SystemExit, which is rarely intended for fallback/default handling.

Files changed:

  • sdk/python/kfp/dsl/v1_modelbase.py (line 135): type conversion fallback
  • sdk/python/kfp/client/client.py (lines 305, 316): k8s config loading fallback
  • sdk/python/kfp/dsl/types/type_utils.py (line 113): JSON parsing fallback

Testing

No behavior change for normal exceptions — except Exception: covers all standard exceptions while allowing KeyboardInterrupt and SystemExit to propagate correctly.

Copilot AI review requested due to automatic review settings March 19, 2026 18:56
@google-oss-prow
Copy link

[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

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

Copy link
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 updates exception handling patterns across three SDK files to comply with PEP 8 E722 by replacing bare except: clauses with except Exception:. This change improves code quality by allowing system exceptions like KeyboardInterrupt and SystemExit to propagate properly while still catching normal exceptions in fallback handling patterns.

Changes:

  • Replace bare except: with except Exception: in type conversion fallback (v1_modelbase.py)
  • Replace bare except: with except Exception: in JSON parsing fallback (type_utils.py)
  • Replace bare except: with except Exception: in Kubernetes config loading fallback (client.py - 2 occurrences)

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
sdk/python/kfp/dsl/v1_modelbase.py Updates exception handling for type conversion fallback pattern
sdk/python/kfp/dsl/types/type_utils.py Updates exception handling for JSON parsing fallback pattern
sdk/python/kfp/client/client.py Updates exception handling for Kubernetes config loading fallback patterns (2 locations)

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.

2 participants