PR: Fix packaging tests and error handling coverage - #8
Conversation
Update python/README.md to match the root README.md exactly. The packaging test verifies that both READMEs are identical to prevent the PyPI package from shipping stale documentation. This was failing because python/README.md had drifted from the canonical README. Fixes: Test failure "python/README.md has drifted from the repo README"
Replace manual Windows path slicing with Node.js standard path.relative() to properly compare filesystem paths across all platforms. The test was computing relative paths by manually slicing the root path length, which failed on Windows where URL pathnames use /D:/ format while filesystem paths use D:\ format. This caused the test to fail: AssertionError: ..\..\..\D:\Project%20V2\... is referenced but not in files Use fileURLToPath() to convert URL pathnames back to filesystem paths, then use path.relative() for robust cross-platform comparison. Fixes: Packaging test fails on Windows
Replace manual Windows path slicing with Node.js standard path.relative() to properly compare filesystem paths across all platforms. The test was computing relative paths by manually slicing the root path length, which failed on Windows where URL pathnames use /D:/ format while filesystem paths use D:\ format. This caused the test to fail: AssertionError: ..\..\..\D:\Project%20V2\... is referenced but not in files Use fileURLToPath() to convert URL pathnames back to filesystem paths, then use path.relative() for robust cross-platform comparison. Fixes: Packaging test fails on Windows
…dling - Add error test for unknown_provider (400) mapping to ConiferModelNotFoundError - Fix packaging test to use path.relative() for cross-platform compatibility - Sync python/README.md with root README.md - Remove unnecessary whitespace from packaging test for clean diff
Greptile SummaryThe PR adds coverage for
Confidence Score: 4/5The UNC path conversion should be corrected before merging because the packaging test still fails for Windows repositories located on network shares. The new conversion handles ordinary drive-letter paths but loses the hostname when a package target originates from a UNC file URL, producing a filesystem path under the wrong root. Files Needing Attention: tests/packaging.test.ts
|
| Filename | Overview |
|---|---|
| tests/errors.test.ts | Adds focused coverage for the existing unknown-provider error mapping without changing runtime behavior. |
| tests/packaging.test.ts | Improves drive-letter path handling, but reconstructing URLs from pathnames still breaks Windows UNC checkouts. |
Prompt To Fix All With AI
### Issue 1
tests/packaging.test.ts:99
**UNC hostname is discarded**
When the tests run from a Windows UNC checkout, `target()` returns a pathname without the file URL's hostname and this line reconstructs a hostless URL, causing `relative()` to compare paths under different roots and fail the packaging assertion for valid artifacts.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.Reviews (1): Last reviewed commit: "Removed Whitespaces in packaging.test.ts" | Re-trigger Greptile
| const relative = path.slice(root.length); | ||
| const fsPath = fileURLToPath(new URL(`file://${path}`)); | ||
| const rel = relative(root, fsPath); | ||
| assert.ok( |
There was a problem hiding this comment.
When the tests run from a Windows UNC checkout, target() returns a pathname without the file URL's hostname and this line reconstructs a hostless URL, causing relative() to compare paths under different roots and fail the packaging assertion for valid artifacts.
Prompt To Fix With AI
This is a comment left during a code review.
Path: tests/packaging.test.ts
Line: 99
Comment:
**UNC hostname is discarded**
When the tests run from a Windows UNC checkout, `target()` returns a pathname without the file URL's hostname and this line reconstructs a hostless URL, causing `relative()` to compare paths under different roots and fail the packaging assertion for valid artifacts.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.|
Thanks for the contribution! Both fixes are solid: the One request before we merge: could you drop the cosmetic reformatting in Also happy to squash the commit history on merge, so no need to rewrite that. |
|
@charlespers Sorry for that I used a Formatting Tool but the blast radius was too much and instead of just working on one function it affected the whole File. |
|
@charlespers Just dropped the cosmetic reformatting in tests/packaging.test.ts. |
Conifer SDK: Test Coverage & Cross-Platform Fixes
Overview
This PR addresses two distinct issues found in the packaging and test suite:
unknown_providererrorsFiles Touched
Detailed Changes
Commit 1: Add error test for unknown_provider
File:
tests/errors.test.tsWhat Changed: Added a new test case to verify that a 400 response with
error_id: "unknown_provider"correctly maps toConiferModelNotFoundError. Also added trailing newline at end of file.After:
Why:
Commit 2: Fix cross-platform path handling in packaging test
File:
tests/packaging.test.tsWhat Changed: Replaced manual Windows path slicing with Node.js standard
path.relative()for robust cross-platform path comparison. Also removed unnecessary whitespace for a clean diff.Problem (Windows-specific failure):
The root cause:
target()returns URL pathnames:/D:/Project%20V2/...(format from.pathname)rootis a filesystem path:D:\Project V2\...(fromfileURLToPath)root.lengthfails because formats don't match...\...\D:\...Before:
After:
Imports Required:
Why:
Technical Details:
URL Conversion:
fileURLToPath(new URL(file://${path}))/D:/Project%20V2/...→D:\Project V2\...%20→ space)rootandfsPathare filesystem pathsPath Comparison:
relative(root, fsPath)dist/src/index.json all platformsTest Results
Both commits together fix these test failures:
Before
After
Verification Checklist
npm testincludes new error test and it passesnpm testpasses on Windows, macOS, Linuxnpm testCommit Messages
Commit 1
Commit 2
Impact Summary
Review Notes
Related Issues
Addresses the following test suite findings: