Page MenuHomePhabricator

Make blame UI recover gracefully if Identities haven't been built yet for a commit

Authored by epriestley on Jan 4 2019, 10:14 PM.



See PHI1014. We may not have Identities if you race the import pipeline, or in some other cases which are more "bug" / "missing migration"-flavored.

Load the commit data so we can fall back to it if we don't have identities.

Test Plan
  • Wiped out all my identities with UPDATE ... SET authorIdentityPHID = NULL WHERE ....
  • Before change: blame fataled with Attempting to access attached data on PhabricatorRepositoryCommit (via getCommitData()), but the data is not actually attached..
  • After change: blame falls back gracefully.
  • Restored identities with bin/repository rebuild-identities, checked blame again.

Diff Detail

rP Phabricator
Automatic diff as part of commit; lint not applicable.
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

epriestley created this revision.Jan 4 2019, 10:14 PM
epriestley requested review of this revision.Jan 4 2019, 10:17 PM
amckinley accepted this revision.Jan 4 2019, 10:21 PM
amckinley added inline comments.

Couldn't this still result in a race? Or do we write to repository_commit and repository_commitdata inside a transaction?

This revision is now accepted and ready to land.Jan 4 2019, 10:21 PM
epriestley added inline comments.Jan 4 2019, 11:03 PM

We can still race and read the Commit before it has CommitData. For most other objects, we'd fail the load and end up in trouble again.

However, in the special case of Commit, if we ask for CommitData and it doesn't exist yet, we get a dummy/empty one instead of a "you didn't ask for commit data but are trying to use it now" exception, specifically because stuff can race the creation of CommitData.

I didn't actually verify that an empty/default CommitData doesn't hit some other error, but from inspection it looks like it will be okay (we'll just end up with a null authorPHID, which the code should probably handle anyway).

Specifically, in CommitQuery near line 400, we do this:

if (!$commit_data) {
  $commit_data = new PhabricatorRepositoryCommitData();

In most other applications, that would be:

if (!$commit_data) {
} drop the result.

This revision was automatically updated to reflect the committed changes.