Repository navigation
fix(session): include root cause for invalid project, region, or session template - #229
Conversation
There was a problem hiding this comment.
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.
1b2d66b to
4492068
Compare
tim-u
left a comment
There was a problem hiding this comment.
Nit, but it'll be permanent in history: the commit message has a local path pasted into the endpoint pattern. It reads "(<region> /usr/local/google/home/dborowitz/.gemini/config/-dataproc.googleapis.com)"; it should read <region>-dataproc.googleapis.com. Probably worth fixing before merge, since it also leaks a username/home dir.
4492068 to
40fa8a0
Compare
|
Good catch on both points:
|
…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}-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' on
ManagedSparkConnectException so full tracebacks preserve the
underlying gRPC error, and pin ImportError.msg on
PySparkNotInstalledError in unit tests.
- Add unit and integration tests covering invalid project IDs, invalid
regions, and nonexistent or malformed session templates.
40fa8a0 to
62c3284
Compare
When
create_sessionfails 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:MethodNotImplementedalongsideInvalidArgumentandPermissionDenied, and translate HTTP 404 responses from the regional endpoint ({region}-dataproc.googleapis.com) into an actionable message prompting the user to check that the location is a valid Managed Spark region.DebugInfodetails,ErrorInforeasons (CONSUMER_INVALID,RESOURCE_PROJECT_INVALID,LOCATION_POLICY_VIOLATED), andBadRequestfield violations when formatting session creation errors, plus a format hint when a malformedsession_templatereference fails with a genericInvalidArgument.from eonManagedSparkConnectExceptionso full tracebacks preserve the underlying gRPC error, and pinImportError.msgonPySparkNotInstalledErrorin unit tests.