fix: use exact token matching in checkDataStore instead of substring search - #117
Open
SoundMatt wants to merge 1 commit into
Open
fix: use exact token matching in checkDataStore instead of substring search#117SoundMatt wants to merge 1 commit into
SoundMatt wants to merge 1 commit into
Conversation
…search checkDataStore used response_body.find(data_store_) which is a substring search. A store named 'ds' would match 'ds-extended', and a store named 'e' would match the CSV column header 'datastore'. Parse the response body into whitespace-separated tokens and compare each one exactly against data_store_. Add <sstream> which is needed for std::istringstream. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Signed-off-by: Matt Jones <47545907+SoundMatt@users.noreply.github.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.
Problem
checkDataStore()usesresponse_body.find(data_store_) != std::string::npos, which is a substring search. A store named"ds"falsely matches"ds-extended", and a short name like"e"would match the CSV column header"datastore", causing the adapter to report that a store exists when it does not (or vice versa with a name that is a prefix of another).Root cause
The
/datastoresendpoint returns a single-column CSV (header:datastore, rows: store names). Usingfindon the raw body does not respect token boundaries, so any name that is a substring of another token in the response produces a false positive.Fix
Replace
findwith whitespace-tokenised iteration (std::istringstream >> token) and compare each token exactly againstdata_store_. This handles both space-separated and newline-separated responses. Add<sstream>to the includes.