Omit the prefix from KV list query text when there is none - #240
Omit the prefix from KV list query text when there is none#240ayaangazali wants to merge 1 commit into
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
🔗 Linked repositories identifiedCodeRabbit considers these linked repositories for cross-repo context during reviews:
Included review availability: Your plan includes up to 3 reviews per rolling hour; 1 remains after this review. 📝 WalkthroughWalkthroughThe KV instrumentation now records Merge Risk: ⚪ Minimal · up to This localized change removes the incorrect 🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
|
Still reproduces on Green and conflict free since it was opened, and no human has looked at it yet. Happy to close it if the Cloudflare packages are not taking changes right now. |
Defect
Every
kv.list()call that does not pass a prefix writes the literal textlist undefinedtodb.query.texton the KV span. That is the default list call, so it is the common case rather than an edge case.Evidence
instrumentKVFnbuilt the query text by interpolation:The
|| undefinedidiom means "omit this" everywhere else in the file, becausesetAttributesdrops undefined values. Inside a template literal it does the opposite:undefinedstringifies, so the attribute is always present and readslist undefinedwhen no prefix was given.Verified against the file's own
createSpan/mockTracerharness on current main.instrumentKV(kv, 'CACHE').list()setdb.query.texttolist undefined.Fix
Interpolate only when there is a prefix. The attribute stays present either way, so list spans remain consistent with every other KV operation, which always sets it. Truthiness is kept rather than an explicit
undefinedcheck, to match howprefixand the surrounding cursor and limit attributes are already treated.The new test asserts both branches. On the old line it fails with
expected 'list undefined' to be 'list'.One unrelated line is included because it is required, not by choice:
kv.test.tswas the only one of the eight test files in that directory without the/// <reference types="@cloudflare/workers-types" />header, so the pre-commit lint could not resolveKVNamespacein it and rejected the commit. Adding the header matches the other seven.Built this with Claude Code's help and reviewed the diff myself.