-
Notifications
You must be signed in to change notification settings - Fork 8.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[FAB-18509] Stop panic if collection index path is wrong #2726
Conversation
@@ -420,21 +420,26 @@ const ( | |||
// Example for chaincode indexes: | |||
// "META-INF/statedb/couchdb/indexes/indexColorSortName.json" | |||
chaincodeIndexDirDepth = 3 | |||
pathLengthForCCindexes = 5 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pathLengthForCCindexes = 5 | |
pathLengthForCCindexes = 4 |
Path that comes here is of directory only. The file name is not part of this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for the review Manish - this is the output I got from the unit test - with printing the args to the getIndexInfo
function. Includes the index file name
=== RUN TestGetIndexInfo
[getIndexInfo] indexPath=META-INF/statedb/couchdb/indexes/indexColorSortName.json
[getIndexInfo] indexPath=META-INF/statedb/couchdb/collections/collectionMarbles/indexes/indexCollMarbles.json
[getIndexInfo] indexPath=META-INF/statedb/couchdb/indexColorSortName.json
[getIndexInfo] indexPath=META-INF/statedb/couchdb/collections/indexes/indexCollMarbles.json
[getIndexInfo] indexPath=META-INF/statedb/couchdb/collections/indexCollMarbles.json
[getIndexInfo] indexPath=META-INF/statedb/
--- PASS: TestGetIndexInfo (0.00s)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mbwhite Existing TestGetIndexInfo()
has a bug too. It should not pass the path including the index def, i.e., *.json
. The input to getIndexInfo()
comes from the HandleDeployChaincode()
which passes only the directory excluding the actual filename.
We need to fix
TestGetIndexInfo()
- Comments (provided in the const block)
getIndexInfo()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some tests in kvledger
package and integration test also fail after making getIndexInfo()
to consider the full path including the index file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@cendhu ah.. that makes more sense now thanks... what can we say about the directory path that is passed in?
The code as-is is uses '/' to split the path, is it safe to assume the input will not have leading or trailing directory separators?
(aside I assume as well that Fabric is solely intended to work on a Linux filesystem? / not being the universal file separator :-) )
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
func ExtractFileEntries(tarBytes []byte, databaseType string) (map[string][]*TarFileEntry, error) { |
ExtractFileEntries()
. I do not see a unit test for ExtractFileEntries()
. Not sure whether it is tested somewhere and I miss it. Hence, it is better to verify that.
As far as I know, even on Windows, we recommend docker to be used (https://hyperledger-fabric.readthedocs.io/en/release-1.4/prereqs.html) and our docker base image is alpine linux. Hence, /
as a file separator is okay.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After a bit more research I believe there are some in db_test.go. My reading of that function is that it later functions can safely assume there are no leading or trailing /
My background in cross-platform development (pre Docker) has made me question whenever I see anything about a filesystem 'hard coded' like a /
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see. Thanks for confirming.
collectionDirDepth = 3 | ||
collectionNameDepth = 4 | ||
collectionIndexDirDepth = 5 | ||
pathLengthForCollectionindexes = 7 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pathLengthForCollectionindexes = 7 | |
pathLengthForCollectionindexes = 6 |
same as above
9866539
to
d5fedc0
Compare
/ci-run |
Signed-off-by: Matthew B White <whitemat@uk.ibm.com>
@Mergifyio backport release-2.2 |
@Mergifyio backport release-2.3 |
Command
|
Signed-off-by: Matthew B White <whitemat@uk.ibm.com> (cherry picked from commit 1249da2)
Command
|
Signed-off-by: Matthew B White <whitemat@uk.ibm.com> (cherry picked from commit 1249da2)
…#2726) (hyperledger#2745) Signed-off-by: Matthew B White <whitemat@uk.ibm.com> (cherry picked from commit 1249da2)
Signed-off-by: Matthew B White whitemat@uk.ibm.com
Type of change