fix: UUID type backward compatibility by surbhigarg92 · Pull Request #2509 · googleapis/nodejs-spanner · GitHub
Skip to content
This repository was archived by the owner on Mar 4, 2026. It is now read-only.

fix: UUID type backward compatibility#2509

Merged
surbhigarg92 merged 3 commits into
mainfrom
uuid_fix
Jan 22, 2026
Merged

fix: UUID type backward compatibility#2509
surbhigarg92 merged 3 commits into
mainfrom
uuid_fix

Conversation

@surbhigarg92

@surbhigarg92 surbhigarg92 commented Jan 21, 2026

Copy link
Copy Markdown
Contributor

This PR reverts the recent change where UUID-formatted strings were implicitly treated as unspecified (untyped). That change caused regressions for customers relying on UUID-like strings being sent as STRING-typed parameters. This PR restores the default behavior: UUID-formatted strings will now default to STRING, ensuring stability for existing applications.

It fixes #2501

Impact on v8.4.0 Users This change affects users who adopted v8.4.0 and relied on the automatic UUID-to-untyped inference. To correctly send a UUID parameter, you must now explicitly specify the type:

javascript
const [rows1] = await database.run({
sql: "SELECT @value",
params: { value: '550e8400-e29b-41d4-a716-446655440000' },
types: {
value: "uuid" , // Explicitly specifying the type
},
});

Temporary Opt-in Flag To temporarily retain the behavior introduced in v8.4.0 (where UUIDs are treated as unspecified), customers can set the environment variable SPANNER_ENABLE_UUID_AS_UNTYPED=true.

Note: This flag causes a deprecation warning to be emitted and will be removed in a future release.
Recommendation: Customers are strongly encouraged to explicitly specify the type as 'uuid' instead of using this flag.

@surbhigarg92 surbhigarg92 requested review from a team January 21, 2026 08:29
@product-auto-label product-auto-label Bot added size: s Pull request size is small. api: spanner Issues related to the googleapis/nodejs-spanner API. labels Jan 21, 2026
@gemini-code-assist

Copy link
Copy Markdown
Contributor

@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 addresses a backward compatibility issue with UUID types. The change in src/codec.ts correctly adjusts the type inference for UUID strings, so they are now treated as string instead of unspecified. This is a good fix. The related change in src/transaction.ts simplifies parameter encoding by removing filtering for unspecified types, which is a nice cleanup.

My main feedback is that the change in src/codec.ts will likely break an existing unit test. Please see my specific comment for details on how to update the test to align with the new behavior.

I am having trouble creating individual review comments. Click here to see my feedback.

src/codec.ts (1163-1165)

high

This change correctly removes the special handling for UUIDs that was causing them to be inferred as unspecified. Now they will be correctly treated as strings, which fixes the backward compatibility issue.

However, this change will likely cause the test 'should determine if the uuid value is unspecified' in test/codec.ts to fail. Please update this test to reflect the new behavior, asserting that a UUID is now inferred as a string.

For example:

it('should determine if the uuid value is a string', () => {
  assert.deepStrictEqual(codec.getType(uuid.v4()), {
    type: 'string',
  });
});

Comment thread samples/backups-cancel.js Outdated
@product-auto-label product-auto-label Bot added size: m Pull request size is medium. and removed size: s Pull request size is small. labels Jan 22, 2026
@surbhigarg92 surbhigarg92 merged commit 7abb33c into main Jan 22, 2026
24 of 25 checks passed
@surbhigarg92 surbhigarg92 deleted the uuid_fix branch January 22, 2026 13:10
gcf-merge-on-green Bot pushed a commit that referenced this pull request Jan 22, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

api: spanner Issues related to the googleapis/nodejs-spanner API. size: m Pull request size is medium.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

UUID-like strings in struct parameters cause type inference failure

3 participants