Page MenuHomePhabricator

Fix an edge case when trying to pull duplicate refs via Doorkeeper
ClosedPublic

Authored by epriestley on Dec 5 2013, 3:36 AM.
Tags
None
Referenced Files
F14068515: D7709.diff
Tue, Nov 19, 10:29 PM
F14054754: D7709.diff
Sat, Nov 16, 4:33 AM
F14052616: D7709.diff
Fri, Nov 15, 9:36 AM
F14043921: D7709.diff
Tue, Nov 12, 1:56 PM
F14027763: D7709.diff
Fri, Nov 8, 9:07 AM
F14010987: D7709.id.diff
Thu, Oct 31, 2:56 PM
F13999420: D7709.diff
Thu, Oct 24, 2:38 PM
Unknown Object (File)
Sep 20 2024, 5:30 PM
Subscribers

Details

Summary

Report from Asana. In some unclear circumstances, we my attempt to resolve duplicate refs which currently ends up hitting a duplicate key error.

Instead, reference the same external object if we happen to be handed duplicate refs.

Test Plan

Used this script to reproduce the issue. Applied the fix; issue went away:

#!/usr/bin/env php
<?php

require_once 'scripts/__init_script__.php';

$args = new PhutilArgumentParser($argv);
$args->parseStandardArguments();

$ref = id(new DoorkeeperObjectRef())
  ->setApplicationType(DoorkeeperBridgeAsana::APPTYPE_ASANA)
  ->setApplicationDomain(DoorkeeperBridgeAsana::APPDOMAIN_ASANA)
  ->setObjectType(DoorkeeperBridgeAsana::OBJTYPE_TASK)
  ->setObjectID(7253737283629); // Use a new task ID which we've never pulled.

$refs = array(clone $ref, clone $ref);

$asana_user = id(new PhabricatorPeopleQuery())
  ->setViewer(PhabricatorUser::getOmnipotentUser())
  ->withUsernames(array('asana'))
  ->executeOne();

$resolved_refs = id(new DoorkeeperImportEngine())
  ->setViewer($asana_user)
  ->setRefs($refs)
  ->execute();

Diff Detail

Lint
Lint Skipped
Unit
Tests Skipped