Conversation
Current coverage is 55.07%@@ master #1194 diff @@
==========================================
Files 77 77
Lines 12190 12188 -2
Methods 0 0
Messages 0 0
Branches 0 0
==========================================
- Hits 6713 6712 -1
Misses 4559 4559
+ Partials 918 917 -1
|
| }, | ||
| }, | ||
| ) | ||
| service, err := getServiceByName(ctx, c, input) |
There was a problem hiding this comment.
It's probably better to lookup by prefix, then let the caller know the name is ambiguous.
There was a problem hiding this comment.
Any time you are trying to resolve a set to single fuzzy item, this is the behavior to use. In psuedocode, it looks like this:
results := find(query)
switch len(results) {
case 0: not found
case 1: found
default: ambiguous -> error
}
This reduces round trips and ensures that you get the right result. If you don't handle the ambiguous case, you end up with a potential security exploit.
|
@doronp Thanks for the bugfixes, but do you mind taking the time to give your PRs and commit messages descriptive titles? |
Signed-off-by: Doron Podoleanu <[email protected]>
|
@stevvooe Done. |
|
@doronp Thanks! It makes it a lot easier when we're going through all these issues and commits. |
|
Are we good to go with this and PR #1097? |
|
@doronp No. You didn't change the code based on the feedback. |
|
@stevvooe You must mean your comment about the result length. Can you please explain in which case The code will return an arbitrary result instead of stating ambiguous? I re-read it and Each of the private methods ( |
|
@doronp Do the prefix lookup first, as it is least likely to fail. The way the code is written now, it incurs an extra request to get services by prefix. If you query prefix and it is unique, it should only take a single request. There are three cases:
We can have a similar set of cases for query by ID Prefix. I am not sure, but there should be a single index that has both names and ids, queryable by prefix, such that this only takes 1 RPC to do in total. |
see I think @aluzzardi @dongluochen @aaronlehmann and ourselves agree that services and networks should behave the same. What you and @aluzzardi suggest is contradicting. Can we please have a resolution for both issues? |
|
@doronp Yes, they should all behave the same. No, they are not contradictory. I am proposing a matching algorithm that is correct, safe and efficient. This PR is not. Both git and docker implement an algorithm similar to this and it needs to be done here, as well. Please do it or we cannot merge this PR. |
|
@stevvooe You wish to have:
And @aluzzardi
I may have miss understood but isn't short ID==prefix? |
|
@stevvooe Just to clarify |
|
@ezrasilvera @doronp Here is the data model. First, we have a function, given an object that gives you thinks that can look it up. The current function for most objects will returns a name and id: We call this function "vectorization". We take the result and apply the entries in a common reverse index-space, with tuples of So, when we have When we look these up in a dataset, we have no clue whether they are ids or names and we can't make assumptions about their relationships. We can only assume that IDs are unique. We can look at the entries as a table. Here is one with concrete values: On the left, we have a lookup key and on the right we have the target object (or likely an identifier). We show this lexicographically and each tuple is unique. With such a dataset, we can serve queries. The query function has the following signature: From our dataset, here are a few results: Now, we have our problem laid out correctly, we can handle various cases. Given the matched set based on prefix scan of the index, we choose an item or return an error indicating ambiguity. We have the following rules:
The results applied to some queries follow:
In this setup, you ensure that every object is accessible, which is guaranteed by the id uniqueness property. We get both name and id prefix matching, with resolved ambiguities. Impact of mutual name-id cycles (task6, task7 above) is minimized by favoring id over name on exact match. I hope this clarifies the methodology. |
|
closing in favor of #1279 feel free to reopen if this is in error. |
service command should work with id prefix and with name as in network command
see:
#1097
#1096