-
Notifications
You must be signed in to change notification settings - Fork 112
Description
Please make sure you have searched for information in the following guides.
- Search the issues already opened: https://github.com/GoogleCloudPlatform/google-cloud-node/issues
- Search StackOverflow: http://stackoverflow.com/questions/tagged/google-cloud-platform+node.js
- Check our Troubleshooting guide: https://github.com/googleapis/google-cloud-node/blob/main/docs/troubleshooting.md
- Check our FAQ: https://github.com/googleapis/google-cloud-node/blob/main/docs/faq.md
- Check our libraries HOW-TO: https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md
- Check out our authentication guide: https://github.com/googleapis/google-auth-library-nodejs
- Check out handwritten samples for many of our APIs: https://github.com/GoogleCloudPlatform/nodejs-docs-samples
A screenshot that you have tested with "Try this API".
This bug occurs in the client library's parameter type inference logic, not in the Spanner API itself. The API works correctly when types are explicitly provided. The issue is that the client library infers a UUID type for strings matching the UUID format, but then fails to pass this type information to the API.
Link to the code that reproduces this issue. A link to a public Github Repository or gist with a minimal reproduction.
https://github.com/flovouin/nodejs-spanner-bugs/blob/main/uuid-string.ts
A step-by-step description of how to reproduce the issue, based on the linked reproduction.
Run the provided script. The emulator was used for reproduction, but I assume the same behavior would be observed on a production instance. No DDL / specific database is needed.
A clear and concise description of what the bug is, and what you expected to happen.
When passing a struct parameter containing a string field with a UUID-formatted value (e.g., "550e8400-e29b-41d4-a716-446655440000"), the query should execute successfully. The string should be treated as a STRING type, as it was in version 8.3.1.
Instead, version 8.4.0 infers the value as UUID type but fails to include the type information in the API request, causing Spanner to reject the query because it cannot determine the struct field type.
A clear and concise description WHY you expect this behavior, i.e., was it a recent change, there is documentation that points to this behavior, etc. **
The provided code works correctly with version 8.3.1, where UUID-formatted strings are treated as STRING type. This is a regression introduced in 8.4.0.
Strings matching UUID format should not be automatically converted to UUID type. A UUID-formatted string is still a valid string, and existing code relies on this behavior. The automatic type inference breaks backward compatibility for any code that passes UUID-formatted strings without explicit type annotations.
Workaround: Explicitly specify the struct field type:
const [rows] = await database.run({
sql: "SELECT @value.v AS v",
params: { value: Spanner.struct({ v: uuidLikeString }) },
types: {
value: { type: "struct", fields: [{ name: "v", type: "string" }] },
},
});Related discussion: #2235 (comment)