fix(pgdb): strip NUL bytes from generated pk/sk values #163
All Vouch review confidence checks passed
Residual risk 0.14 = Change Risk (0.37) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.37 · 214 lines diff across 2 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.321
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #163"
general
weight: 0.35
pquerna
What
A NUL byte (U+0000) in any field that feeds a message's dynamo-derived pk/sk survives into the generated
pb$pk/pb$skvalues (andPKSK()), while every plain string column already strips it. This PR applies the same strip to the joined pk/sk string infield_dynamo_pksk.tmpl, regenerates the example models, and adds regression tests.Why
Postgres text values can never contain NUL, so a NUL-bearing key makes the row permanently unwritable:
ERROR: invalid message format (SQLSTATE 08P01).Stripping at generation time matches the existing convention for plain string columns and keeps pk/sk consistent with their stripped column counterparts.
Testing
TestRecord_NulByteInKeyField— pk/sk/PKSK contain no NUL for both dialects; fails without the template fix.TestRecord_NulByteInSortKeyField— same, on a field-derived sort key (ScalarValue), sincePet's sk is a constant.TestInsertMany_NulByteInKeyField— end-to-end upsert of a NUL-keyed row throughInsertManyagainst pgtest succeeds.Tradeoff note
Stripping means two keys differing only by an embedded NUL now silently collide (last-writer-wins upsert) instead of failing loudly with 08P01. This matches the long-standing convention for plain string columns, and the previous behavior was that such rows could not be written at all, so no existing data changes keys.
🤖 Generated with Claude Code