Skip to content

fix(session): include root cause for invalid project, region, or session template - #229

Open
dborowitz wants to merge 1 commit into
mainfrom
dborowitz-create-session-errors
Open

dborowitz wants to merge 1 commit into
mainfrom
dborowitz-create-session-errors

Conversation

@dborowitz

Copy link
Copy Markdown
Contributor

When create_session fails due to a typo in the project ID, region, or session template, surface the underlying error details instead of raising an opaque HTTP 404 or dropping structured gRPC metadata:

  • Catch MethodNotImplemented alongside InvalidArgument and PermissionDenied, and translate HTTP 404 responses from the regional endpoint (<region> /usr/local/google/home/dborowitz/.gemini/config/-dataproc.googleapis.com) into an actionable message prompting the user to check that the location is a valid Managed Spark region.
  • Surface structured DebugInfo details, ErrorInfo reasons (CONSUMER_INVALID, RESOURCE_PROJECT_INVALID, LOCATION_POLICY_VIOLATED), and BadRequest field violations when formatting session creation errors, plus a format hint when a malformed session_template reference fails with a generic InvalidArgument.
  • Chain the original exception with from e and make ManagedSparkConnectException inherit from RuntimeError so callers catching either exception type continue to work and full tracebacks preserve the underlying gRPC error.
  • Add unit and integration tests covering invalid project IDs, invalid regions, and nonexistent or malformed session templates.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request improves error handling and reporting when creating a Managed Spark Session. Key changes include changing ManagedSparkConnectException to inherit from RuntimeError, adding detailed error extraction and formatting logic for API errors (such as invalid project IDs, invalid regions, and malformed session templates), and introducing a helper function to clean up failed session creations. Additionally, comprehensive integration and unit tests have been added to verify these error handling paths. There are no review comments to address, and I have no further feedback to provide.

@dborowitz
dborowitz requested a review from tim-u November 3, 2026 02:17
…ion template

When create_session fails due to a typo in the project ID, region, or
session template, explain the underlying failure instead of raising an
opaque HTTP 404 or swallowing structured error details:

- Catch MethodNotImplemented alongside InvalidArgument and
  PermissionDenied, and translate HTTP 404 responses from the regional
  endpoint (<region> /usr/local/google/home/dborowitz/.gemini/config/-dataproc.googleapis.com) into an actionable message
  telling the user to verify that the location is a valid Managed Spark
  region.
- Surface structured DebugInfo details, ErrorInfo reasons
  (CONSUMER_INVALID, RESOURCE_PROJECT_INVALID, LOCATION_POLICY_VIOLATED),
  and BadRequest field violations when formatting session creation
  errors, plus a format hint when a malformed session_template reference
  fails with a generic InvalidArgument.
- Chain the original exception with 'from e' and make
  ManagedSparkConnectException inherit from RuntimeError so callers
  catching either exception type continue to work and full tracebacks
  preserve the underlying gRPC error.
- Add unit and integration tests covering invalid project IDs, invalid
  regions, and nonexistent or malformed session templates.
@dborowitz
dborowitz force-pushed the dborowitz-create-session-errors branch from 1b2d66b to 4492068 Compare November 3, 2026 02:43
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.

1 participant