Skip to content

Conversation

@jy-tan
Copy link
Contributor

@jy-tan jy-tan commented Jan 30, 2026

Summary

Fixes a bug where psycopg2 query parameters were not serialized in replay mode, causing InputValueHash mismatches between record and replay. This resulted in exact hash matching failing and falling back to similarity matching, which could return incorrect mocks.

Changes

  • Added serialize_value(params) in _try_get_mock to ensure parameters are serialized identically to record mode

Root Cause

During recording, parameters were serialized:

input_value["parameters"] = serialize_value(params)  # UUID → {"__uuid__": "..."}

During replay (in _try_get_mock), parameters were passed raw:

input_value["parameters"] = params  # UUID stays as UUID object

This caused different hash values, breaking exact matching for queries containing UUIDs, datetimes, Decimals, and other non-JSON-native types.

Copy link

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 1 file

@jy-tan jy-tan merged commit e5740ca into main Jan 30, 2026
22 checks passed
@jy-tan jy-tan deleted the psycopg2-replay-serialize-params branch January 30, 2026 05:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants