Repository navigation
Conversation
Index.PutMulti sizes the returned appengine.MultiError to len(res.Status) and returns it (with res.DocId) as soon as any per-document status is non-OK. The check that the response length matches the number of documents sent only runs on the success path, so an IndexDocument response that is shorter or longer than the request and also carries a non-OK status skips it entirely. MultiError is documented to be the same size as srcs with element i corresponding to srcs[i], so a mismatched response hands callers a MultiError whose indices no longer line up: code iterating by source index panics with an out-of-range access, or attributes an error to the wrong document. DeleteMulti already guards against this by checking len(res.Status) against the request before building its MultiError. Do the same in PutMulti: validate len(res.Status) == len(docs) first and size the MultiError to len(docs), keeping the DocId-length check on the success path where the backend returns one ID per document. Signed-off-by: usama khan <usama@bugqore.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Index.PutMulti sizes the returned MultiError to len(res.Status) and returns it with res.DocId as soon as a per-document status is non-OK, so the length check that guards against a short or mismatched IndexDocument response only runs on the success path and is skipped whenever the response also carries an error status. MultiError is documented as the same size as srcs with element i corresponding to srcs[i], so a mismatched response gives callers a MultiError whose indices no longer line up: iterating by source index panics with an out-of-range access or misattributes an error to the wrong document. DeleteMulti already validates len(res.Status) against the request before building its MultiError; this applies the same guard in PutMulti and keeps the DocId-length check on the success path.
Applied to the v2 module as well, with a regression test in both.