GoogleCloudPlatform / GoogleCloudPlatform/spring-cloud-gcp
[Spanner ORM] INVALID_ARGUMENT: Type code must be specified (code: 17) when using nested @Interleaved lists in Spring Boot 3.5.x + GCP 7.0.0
- Dominant language
- Java
- Stars
- 551
- Forks
- 349
- Avg merge
- 1d 13h
- Merged PRs (30d)
- 14
Description
# [Spanner ORM] INVALID_ARGUMENT: Type code must be specified (code: 17) when using nested @Interleaved lists in Spring Boot 3.5.x + GCP 7.0.0
## Summary
After upgrading our application from:
- **Spring Boot**: `3.4.5` → `3.5.3`
- **Spring Cloud GCP dependencies**: `com.google.cloud:spring-cloud-gcp-dependencies` from `6.1.1` → `7.0.0`
we are encountering a `SpannerException` related to type inference while working with nested `@Interleaved` entities using Spring Data Spanner ORM.
## Error
```
com.google.cloud.spanner.SpannerException: INVALID_ARGUMENT: io.grpc.StatusRuntimeException: INVALID_ARGUMENT: Type code must be specified, found code: 17
- Statement: 'SELECT job_id, ARRAY (SELECT AS STRUCT job_id, task_id, ARRAY (SELECT AS STRUCT job_id, task_id, cause_id FROM cause WHERE cause.job_id = task.job_id AND cause.task_id = task.task_id) AS causes FROM task WHERE task.job_id = job.job_id) AS tasks FROM job WHERE (job_id = @tag0)'
```
This occurs when executing a query involving nested `ARRAY(SELECT AS STRUCT ...)` subqueries, which Spring Data Spanner automatically constructs due to `@Interleaved` relationships.
## Entity Structure (Simplified)
```java
@Entity
public class JobEntity {
@PrimaryKey
private String jobId;
@Interleaved
private List tasks = new ArrayList<>();
}
@Entity
public class TaskEntity {
@PrimaryKey(keyOrder = 1)
private String jobId;
@PrimaryKey(keyOrder = 2)
private String taskId;
@Interleaved
private List causes = new ArrayList<>();
}
@Entity
public class CauseEntity {
@PrimaryKey(keyOrder = 1)
private String jobId;
@PrimaryKey(keyOrder = 2)
private String taskId;
@PrimaryKey(keyOrder = 3)
private String causeId;
}
```
## Findings
- Marking the `tasks` field with `@NotMapped` avoids the error, confirming that the issue is directly tied to mapping the interleaved structure.
- However, this breaks the application's behavior since the interleaved data is needed.
- The error **only occurs after upgrading** to Spring Boot `3.5.3` and Spring Cloud GCP `7.0.0`.
- The exact same codebase **works without error** when using Spring Boot `3.4.5` and Spring Cloud GCP `6.1.1`.
## Hypothesis
The Spanner ORM fails to infer or register the `TypeCode` for a nested `ARRAY>` during deserialization, likely due to:
- Changes in Spring Boot 3.5.x’s `ConversionService` or type binding infrastructure.
- A missing or improperly configured `SpannerCustomConversions` entry for nested or interleaved list handling.
- Incomplete support for multi-level interleaved hierarchies in Spring Cloud GCP 7.0.0.
## Request
Could you please confirm:
- Whether this is a known limitation or regression in Spring Cloud GCP 7.0.0?
- Whether additional configuration or custom converters are required in Spring Boot 3.5.x to support nested `@Interleaved` lists?
- If a fix is planned or already in progress?
Thank you!
Contributor guide
Assessment
This issue has not been assessed yet.