Fix sharing methods failing with 404 due to double-applied query params#197
Conversation
All sharing.* methods (listAssetShares, getAssetShare, shareAsset, updateAssetShare, deleteAssetShare) baked assetType/assetId into the request URL and then passed queryParameters through to the HTTP layer, which re-applied them via axios params. This produced a duplicated, malformed query string and a leading double-slash, causing the API to return 404 Not Found. URL construction now follows the reports module pattern: a path-only url plus queryParameters serialized once by the requestor. Also adds a patch method to httpRequestor so updateAssetShare (PATCH) works, and adds mock API tests for all five sharing endpoints. Fixes #195 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (6)
🚧 Files skipped from review as they are similar to previous changes (6)
📝 WalkthroughWalkthroughSharing methods now delegate query serialization to request options, ChangesSharing API fixes and validation
Estimated code review effort: 3 (Moderate) | ~20 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
Coverage Report for CI Build 29838576193Warning No base build found for commit Coverage: 97.619%Details
Uncovered ChangesNo uncovered changes found. Coverage RegressionsRequires a base build to compare against. How to fix this → Coverage Stats💛 - Coveralls |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@test/mock-api/sharing/list_asset_shares.spec.ts`:
- Around line 51-57: Ensure each sharing request test asserts query-key
cardinality using searchParams.getAll(): add exactly one assetType and one
assetId assertion in test/mock-api/sharing/list_asset_shares.spec.ts:51-57,
test/mock-api/sharing/delete_asset_share.spec.ts:45-46,
test/mock-api/sharing/get_asset_share.spec.ts:40-41,
test/mock-api/sharing/share_asset.spec.ts:69-74, and
test/mock-api/sharing/update_asset_share.spec.ts:45-46, while retaining the
existing complete query-map assertions.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 12dc8fbf-b3e3-4650-b6e4-c81ed3218024
📒 Files selected for processing (9)
CHANGELOG.mdlib/sharing/index.tslib/utils/httpRequestor.jstest/mock-api/sharing/common_test_constants.tstest/mock-api/sharing/delete_asset_share.spec.tstest/mock-api/sharing/get_asset_share.spec.tstest/mock-api/sharing/list_asset_shares.spec.tstest/mock-api/sharing/share_asset.spec.tstest/mock-api/sharing/update_asset_share.spec.ts
Object.fromEntries() collapses repeated query keys, so the original double-applied assetType/assetId bug would still satisfy the URL assertions. Comparing parsedUrl.searchParams against an expected URLSearchParams verifies key cardinality, making these real regression tests for #195. Addresses CodeRabbit review on PR #197. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Summary
Fixes #195. All
sharing.*methods failed with404 Not Found(errorCode 1006) against the real API because each method bakedassetType/assetIdinto the request URL string and passedqueryParametersthrough to the generic HTTP requestor, which re-applied them via axiosparams. The result was a duplicated, malformed query string (and a leading double-slash frombaseUrl = '/shares'), which the API could not route.listAssetShares,getAssetShare,shareAsset,updateAssetShare,deleteAssetShare) to follow the reports module pattern: a path-onlyurlplusqueryParametersserialized once by the requestor.patchmethod tolib/utils/httpRequestor.js.updateAssetSharecalledrequestor.patch(...), which did not exist — the method threw at runtime regardless of the query-param bug.test/mock-api/sharing/.Proof of fix
Capturing the exact wire URL the SDK emits, before vs. after:
Before (buggy):
After (fixed):
The fixed URL matches the known-working
curlfrom the issue exactly.Test plan
npm run buildsucceedsnpx jest test/mock-api/sharing— 24 tests pass across 5 suites (requires WireMock on :8082)httpRequestor.jschangenpx eslint— 0 errors on changed files🤖 Generated with Claude Code
Summary by CodeRabbit
404 Not Founderrors caused by Sharing API query parameters being applied twice.