fix: address PR review feedback on test isolation and undefined property encoding#130
fix: address PR review feedback on test isolation and undefined property encoding#130
Conversation
…ps, unused type) Agent-Logs-Url: https://github.com/Looted/kibi/sessions/3d0a4d79-9903-4572-9709-bdd79879f7d8 Co-authored-by: Looted <6255880+Looted@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR addresses prior review feedback around test cleanliness/isolation and Prolog goal encoding, primarily by removing unused test-only symbols, restoring env vars correctly, and preventing accidental "undefined" serialization in entity upserts.
Changes:
- Remove unused imports/type aliases in VS Code extension tests to satisfy lint/CI.
- Fix
KIBI_MCP_DEBUGenv var restoration to delete the key when initially unset. - Update MCP upsert property encoding to skip
undefined/nullentity properties and adjust the related test assertion.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| packages/vscode/tests/treeProvider.test.ts | Removes an unused TreeProviderInstance type alias. |
| packages/vscode/tests/hoverProvider.test.ts | Removes unused real helper destructuring imports, keeping only the used symbol. |
| packages/mcp/tests/tools/upsert.test.ts | Restores KIBI_MCP_DEBUG correctly and updates assertion to ensure owner isn’t encoded when undefined. |
| packages/mcp/src/tools/upsert.ts | Skips undefined/null values when building the entity property list for Prolog transactions. |
| for (const [key, value] of Object.entries(entity)) { | ||
| if (key === "type") continue; | ||
| if (value === undefined || value === null) continue; | ||
|
|
There was a problem hiding this comment.
buildPropertyList now skips undefined/null, which fixes accidental "undefined" strings for entity properties, but the relationship encoder (buildRelationshipMetadata) still stringifies undefined (e.g. source="undefined") because Ajv treats undefined as “missing” and allows it through. Consider applying the same value === undefined (and/or null) skip logic to buildRelationshipMetadata as well so relationship metadata doesn’t persist the literal string "undefined".
|
|
||
| for (const [key, value] of Object.entries(entity)) { | ||
| if (key === "type") continue; | ||
| if (value === undefined || value === null) continue; |
There was a problem hiding this comment.
The value === null branch here is likely unreachable because entitySchema declares properties as non-nullable and Ajv will fail validation for null (unlike undefined, which Ajv treats as missing). Consider either dropping the null check to avoid implying null is supported, or explicitly documenting/adjusting validation if null is intended to be accepted.
| if (value === undefined || value === null) continue; | |
| if (value === undefined) continue; |
Four issues flagged in code review: unused imports that could fail Biome CI checks, incorrect env var restoration in
afterEach, accidental serialization ofundefinedas"undefined"in the Prolog encoder, and an unused type alias.Changes
hoverProvider.test.ts: Remove unusedrealCategorizeEntitiesandrealFormatLensTitlefrom thehelpers?realdestructuring import.treeProvider.test.ts: Remove declared-but-unreferencedTreeProviderInstancetype alias.upsert.test.ts— env var restoration: CaptureKIBI_MCP_DEBUGasstring | undefined; delete the key on restore when it was originally unset instead of writing"".upsert.ts—buildPropertyList: Skipundefined/nullvalues rather than falling through toString(value)which emitsowner="undefined"into the Prolog transaction goal.Test assertion updated from
toContain('owner="undefined"')→not.toContain("owner=").