googleapis / googleapis/google-cloud-java

[java-spanner] [FR] Improve error messaging for Table type mismatches

Đang mở
#12,232 0 bình luận 0 reaction 1 người được giao Được @rahul2393 nhận Xem trên GitHub
api: spanner
Ngôn ngữ chính
Java
Star
2.1k
Fork
1.2k
Merge trung bình
1 ngày 23 giờ
Pull request đã merge (30 ngày)
154

Mô tả

- **Is this a bug or feature request?** Feature Request (Enhancement)
- **Current Behavior:** When a field type does not match the Spanner table definition (e.g., String vs Boolean in Table), the client throws a generic INVALID_ARGUMENT: invalid mutation key error. This makes debugging difficult as it does not specify which column caused the failure.
- **Expected Behavior:** The exception should ideally identify the specific column name and the type mismatch (e.g., "Expected BOOL for column 'isValid', but received STRING").
- **Example (unhelpful) Error:**
```
Caused by: com.google.cloud.spanner.SpannerException: INVALID_ARGUMENT: io.grpc.StatusRuntimeException: INVALID_ARGUMENT: Failed to initialize transaction due to invalid mutation key. - RequestId: 1.e93046ae8a546107.1.1.112.1
      at com.google.cloud.spanner.SpannerExceptionFactory.newSpannerExceptionPreformatted(SpannerExceptionFactory.java:359)
      at com.google.cloud.spanner.SpannerExceptionFactory.fromApiException(SpannerExceptionFactory.java:379)
      at com.google.cloud.spanner.SpannerExceptionFactory.newSpannerException(SpannerExceptionFactory.java:192)
      at com.google.cloud.spanner.SpannerExceptionFactory.newSpannerException(SpannerExceptionFactory.java:115)
      at com.google.cloud.spanner.SessionImpl.lambda$beginTransactionAsync$3(SessionImpl.java:507)
      ... 51 more
```

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.