Page MenuHomePhabricator

Owners has perplexing behavior when directory paths are not terminated with a slash
Closed, ResolvedPublic

Description

I set up an Owners package covering our entire ansible folder and set up what I believe to be the strongest settings, and then asked someone who definitely isn't part of the owner group to submit a review changing a file inside the monitored path, specifying another member outside the owner group as a reviewer.

expect: members of the owner group to receive notification of this and be flagged as blocking reviewers of the review

actual: review didn't set off any triggers, almost as if the owners package wasn't defined at all

owner package setup:

Screen Shot 2016-05-23 at 16.41.28.png (701×493 px, 51 KB)

diffusion showing a review affects the path marked as being monitored:

Screen Shot 2016-05-23 at 16.42.11.png (333×420 px, 33 KB)

review shows Herald ran but only CCd "all code reviews".

Screen Shot 2016-05-23 at 16.42.36.png (794×595 px, 83 KB)

not entirely sure if I did something wrong / misunderstood the intended functionality and behavior, or if broken.

Event Timeline

Try /wsl_root/src/ansible/ (with a trailing slash)?

that worked. there's no indication in the UI that the trailing slash is required, the link rendered works fine

also, I would not expect it to fail in this direction... if I added a slash there and it wasn't necessary, I can see it failing due to double-slashing, but as it is (and with the expectation that "everything below is covered"), I would expect it to work either way

in my opinion, either the feature needs to be resilient and work with or without a trailing slash, or verify the path exists and is a file (I'm guessing this is the case for no slash?) otherwise raise a visual warning that it's misconfigured

I ran into an identical issue (and debugged on chat). Agreed that there could be better messaging around this.

Yeah, current behavior is garbage. Not sure if I changed it by accident while doing other changes or we just didn't run into it before, but there's no technical or product reason for it to work like it currently does.

epriestley renamed this task from Owners not picking up code reviews, unclear if properly configured to Owners has perplexing behavior when directory paths are not terminated with a slash.May 23 2016, 4:34 PM
epriestley added a project: Owners.

We have a somewhat-legitimate technical reason for this behavior: when we compute which-packages-own(list-of-paths), we do so by splitting the paths into components and then querying for the components. a/b/ is the best database representation for this.

We could normalize everything to this form, which would be good from a technical point of view, but would mean that you'd type a/important.c and we'd store and display a/important.c/, which would have the same effect but likely be confusing.

Probably better is to add pathIndex, store hash(normal(path)) there, normalize everything to /a/important.c/ form internally, and keep path as the human-readable display value, but this involves some migrations and work and needs to touch a few things.

I don't think this behavior changed, it appears to be present when Owners came out of Facebook in rP23f882a0, circa 2011.

Probably better is to add pathIndex

Specifically, the issue here is that paths may be arbitrarily long but path is currently a text255, so Owners can't actually interact with path rules that apply to paths with more than 255 characters today. Fortunately, these have yet to crop up in the wild, I think.

I'm going to make these changes:

  • Add pathIndex, a new hash digest column.
  • Begin populating pathIndex when OwnersPath records are saved.
  • Migrate the OwnersPath table to store a digest of path in pathIndex.
  • Migrate the OwnersPath table to remove rows with a duplicate <packageID, repositoryPHID, pathIndex> tuple. This is not currently enforced at the database level.
  • Add a unique key to <packageID, repositoryPHID, pathIndex>.
  • Modify path to LONGTEXT. Ideally, this should be LONGBLOB because paths may not be UTF8, but I'm comfortable saying that the Owners tool can not interact with non-UTF8 path rules for the forseeable future.
  • Add pathDisplay.
  • Begin populating pathDisplay when OwnersPath records are saved.
  • Migrate the OwnersPath table to set pathDisplay = path.
  • Add code to normalize path on save.
  • Show the user pathDisplay in the UI.

Also T12590 is pretty egregious and should really get fixed. I think we have the technology nowadays.

epriestley claimed this task.

I believe the behavior of this UI should generally align well with what reasonable users might expect, now. In particular, /src/backend and /src/backend/ are now exactly the same in terms of actually resolving ownership, although the UI will continue to show you the value you entered (to avoid confusion where someone types /docs/README.md and the UI echoes back /docs/README.md/ and they have a reasonable concern that the path wasn't understood).

In D19185, I was able to improve the performance of some Owners queries based on these changes. I don't expect this to result in a dramatic performance change, but it should be a little better.

Owners also now supports arbitrarily long paths (previously, you were limited to entering values of less than 255 characters). This only applies to the length of patterns you enter in the UI: /src/ could still match /src/...<thousands of characters>.../whatever.c before this change. You just couldn't enter /src/external/vendor/com/java/java/org/.../ if the rule you wanted to write involved specifying a path with more than 255 characters.

It does not yet support non-UTF8 paths, and I have no particular plans to add this support, partly because it would be difficult for users to enter non-UTF8 paths in the UI or via the API, and partly because non-UTF8 paths are a morally distasteful abomination.