Skip to content

Conversation

@andyatmiami
Copy link
Contributor

ℹ️ : NO GH ISSUE

chore: improve validation and error response handling

This commit delivers improvements to validation and error handling across the backend API.

Key changes:

Error Response Improvements:

  • Enhanced error response structure with origin tracking (INTERNAL vs KUBERNETES)
  • Added support for extracting StatusCauses from both Invalid and Conflict Kubernetes errors via StatusCausesFromAPIStatus helper
  • Improved conflict error handling to always include origin field in API responses, ensuring pause action conflicts show KUBERNETES origin
  • Added comprehensive test coverage for error response functions

Validation Enhancements:

  • Refactored workspace model types (types_create.go -> types_write.go) for better code organization
  • Enhanced validation helper functions with improved error extraction
  • Added IsEOFError handling for better empty request body detection
  • Improved webhook validation for WorkspaceKind resources

Handler Updates:

  • Updated PauseActionWorkspaceHandler to properly handle Invalid errors from Kubernetes patch operations, ensuring conflict_causes[] includes KUBERNETES origin
  • Enhanced CreateWorkspaceHandler and other handlers to utilize improved error extraction and response formatting
  • Updated workspace and workspacekind handlers to use new validation and error response patterns

Testing:

  • Added comprehensive test suite for response_errors.go
  • Added extensive validation helper tests
  • Updated existing handler tests to match new error response format

thesuperzapper and others added 2 commits November 7, 2025 11:13
Signed-off-by: Mathew Wicks <[email protected]>

Signed-off-by: Andy Stoneberg <[email protected]>
- Updated StatusCausesFromAPIStatus to also return causes from StatusReasonConflict
- Enhanced PauseActionWorkspaceHandler and CreateWorkspaceHandler to utilize IsEOFError for better error responses.
- Enhanced PauseActionWorkspaceHandler to ensure conflict_causes[] is present when Patch operation returns Invalid
- Introduced new test files for response error handling and validation helper functions.

Signed-off-by: Andy Stoneberg <[email protected]>
@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 ask for approval from andyatmiami. For more information see the Kubernetes Code Review Process.

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

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 google-oss-prow bot added the area/backend area - related to backend components label Nov 7, 2025
@google-oss-prow google-oss-prow bot added area/controller area - related to controller components area/v2 area - version - kubeflow notebooks v2 size/XXL labels Nov 7, 2025
@andyatmiami andyatmiami changed the title Chore/validation improvements chore: improved validation and error responses Nov 7, 2025
@andyatmiami
Copy link
Contributor Author

/ok-to-test

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

Labels

area/backend area - related to backend components area/controller area - related to controller components area/v2 area - version - kubeflow notebooks v2 ok-to-test size/XXL

Projects

Status: Needs Triage

Development

Successfully merging this pull request may close these issues.

2 participants