Skip to content
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

chat: handle suffixes and readers when adding username to TLF #16067

Merged
merged 2 commits into from Feb 25, 2019

Conversation

strib
Copy link
Contributor

@strib strib commented Feb 14, 2019

Otherwise a valid TLF name like "a,b (conflicted copy 2019-02-14 #1)" becomes "a,b (conflicted copy 2019-02-14 #1),a" and everything breaks.

@strib strib requested a review from mmaxim February 14, 2019 23:36
@mmaxim
Copy link
Contributor

mmaxim commented Feb 14, 2019

Why is this needed? I was hoping to not have to think about these suffixes again.

@strib
Copy link
Contributor Author

strib commented Feb 15, 2019

@mmaxim so we can get the kbfsfileedits inbox for say /keybase/private/a,b (conflicted copy 2017-04-21). With the current code, GetInboxAndUnboxLocal returns an error. This happened today to someone (see the keybase#kbfs channel).

Copy link
Contributor

@mmaxim mmaxim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe all this stuff could get moved to a helper function that only runs if membersType == chat1.ConversationMembersType_KBFSFILEEDIT. I'd like to keep any change here narrow for this fix.

@strib
Copy link
Contributor Author

strib commented Feb 19, 2019

@mmaxim I can do that, but it seems like this function is just broken, and if any future users try to use it for non-standard TLF names under a different chat type, it will just break. I would prefer not to have broken code in the codebase.

Note that the changes I made were ported over directly from assertion.go:

split1 := strings.SplitN(s, " ", 2) // split1: [assertions, ?conflict]
split2 := strings.Split(split1[0], "#") // split2: [writers, ?readers]
if len(split2) > 2 {
return ret, NewImplicitTeamDisplayNameError("can have at most one '#' separator")
}
seen := make(map[string]bool)
var readers, writers keybase1.ImplicitTeamUserSet
writers, err = parseImplicitTeamUserSet(ctx, split2[0], seen)
if err != nil {
return ret, err
}
if writers.NumTotalUsers() == 0 {
return ret, NewImplicitTeamDisplayNameError("need at least one writer")
}
if len(split2) == 2 {
readers, err = parseImplicitTeamUserSet(ctx, split2[1], seen)
if err != nil {
return ret, err
}
}

So the code is already being exercised on probably every chat path anyway, just not in this function, making it inconsistent.

The other alternative is just not calling this function at all for kbfs RPCs, because we'll always give you a TLF name that includes the logged-in user. I guess that would be the most efficient thing, but it still leaves the code very broken.

@mmaxim
Copy link
Contributor

mmaxim commented Feb 20, 2019

Alternative sounds great, just exit this function if membersType == chat1.ConversationMembersType_KBFSFILEEDIT.

@strib
Copy link
Contributor Author

strib commented Feb 20, 2019

Ok. I'll leave a big comment that this function is completely broken for non-standard TLFs.

@mmaxim
Copy link
Contributor

mmaxim commented Feb 20, 2019

The notion of a TLF name in chat isn't really a thing anymore. They are called that, but only because of the now defunct dependency on KBFS. There is no way to create anything other than a list of usernames, which is all this function is trying to do. The hope going forward is to not have to think about suffixes or readers or whatever else (stuff that would have never been a factor in a program that didn't have a connection to KBFS), and that all works except for this particular case where this other force is putting these names in there (and we aren't stopping it).

@strib
Copy link
Contributor Author

strib commented Feb 20, 2019

Actually @mmaxim on second thought, will bailing out of this function early break command line API calls for kbfsfileedit content?

I assume there are still old conversations with suffixes etc that still could get tripped up by this function.

@strib
Copy link
Contributor Author

strib commented Feb 20, 2019

@mmaxim ping on above question.

Also, I just tried creating a conflicting conversation by making one conversation with a user, one conversation with a social assertion (and the same thing with the corresponding folders), and then later proving the social assertion. Not only does it give me two duplicate chats in my inbox (probably known and maybe desired?), but if I click the chat button from the folder with the "conflicting" suffix, it creates yet a third entry. Interestingly, it does not seems to exercise the function I changed here (doing it with or without my PR yields the same behavior, and the "malformed suffix" error doesn't show up in the log).

So I'm still not sure why we shouldn't change this function -- it doesn't seem to affect current behavior except in the kbfs case, and it's very broken. But I'll change it to have my alternate version above if you don't think it will break API calls for kbfsfileedit chat content.

@strib
Copy link
Contributor Author

strib commented Feb 20, 2019

Another option might be to factor out the existing code of the assertion parser and re-use it here, if you think that will be safer.

Also happy to add like 20 TLF-name-parsing tests to the test file here, if you want. Should be pretty easy.

@mmaxim
Copy link
Contributor

mmaxim commented Feb 20, 2019

It is intended to give you two conversations. I don't know what the folder icon stuff is doing, but likely it is creating one with the suffix on it to get the third, which isn't great. That stuff should be dropping the suffix on whatever operation it is performing.

I think the real mistake on my part is not just rejecting these TLF names with suffixes on them for any of the implicit team backed conversations. Right now it just sends them through the implicit team name parser which will just accept it, which is unfortunate, but seemingly required for the KBFS file edit stuff to work now.

@strib
Copy link
Contributor Author

strib commented Feb 20, 2019

Yes, it's required to get the edit history for conflict folders

What does that mean it terms of this PR? Which version do you prefer? Options:

  1. This PR as is. (I can add tests if that helps.)
  2. A helper function that's only called for kbfsfileedit types, which addresses the suffix issue.
  3. Same as above, but that helper is shared with assertion.go.

Copy link
Contributor

@mmaxim mmaxim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok we can just do this, although a test wouldn't hurt. It would also be great to put a comment above all this logic that mentions that KBFS can create chats with these kinds of names and this helps support that.

Otherwise a valid TLF name like "a,b (conflicted copy 2019-02-14 #1)"
becomes "a,b (conflicted copy 2019-02-14 #1),a" and everything breaks.
@strib strib merged commit ee5b742 into master Feb 25, 2019
@strib strib deleted the strib/fix-tlf-name-adding branch February 25, 2019 17:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants