fix: Sanitize index names to support CouchDB > 3.3.3#1668
fix: Sanitize index names to support CouchDB > 3.3.3#1668
Conversation
WalkthroughThe change adds a private helper 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
No actionable comments were generated in the recent review. 🎉 Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
I didn't find a commit from CouchDB relative to this issue, but it's somewhere between 3.3.3 & 3.5.1. Partial filter values containing "/" (e.g. "/Settings") produced index names incompatible with new CouchDB. Percent-encode "/" as "%2F" (and "%" as "%25") to avoid naming issues while preserving uniqueness. Closes #1667
c1e54f3 to
486a2ef
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@packages/cozy-stack-client/src/mangoIndex.spec.js`:
- Around line 258-274: The test's partialFilter defines a $nin array spread
across multiple lines which trips Prettier; update the test "should sanitize
slash characters from index name" so the $nin arrays (both for _id and for
path.$or[1].$nin) are formatted on a single line (e.g. ['$a','/Settings'] style)
to satisfy Prettier, keeping the same values and leaving the rest of the test
and the call to getIndexNameFromFields unchanged.
🧹 Nitpick comments (1)
packages/cozy-stack-client/src/mangoIndex.js (1)
108-118: Consider extractingsanitizeIndexNameto a shared utility.This function is duplicated verbatim in
packages/cozy-pouch-link/src/mango.js. While the existing "Warning" comments remind developers to keep them in sync, a shared module would eliminate the risk of divergence. Low priority given the existing convention in this codebase.
I didn't find a commit from CouchDB relative to this issue, but it's somewhere between 3.3.3 & 3.5.1.
Partial filter values containing "/" (e.g. "/Settings") produced index names incompatible with new CouchDB. Percent-encode "/" as "%2F" (and "%" as "%25") to avoid naming issues while preserving uniqueness.
Closes #1667
Summary by CodeRabbit
Bug Fixes
Tests