Conduit : phriction.document.search OK or 444 or 501 randomly with same parameter

I’m writting script to migrate MediaWiki to phriction, i call API to check if page exist so as to knoww if i need to create or edit. But when i call api in my php script (here : phabricator/scripts/uti/l) randomly i have a response or error with exactly the same call.

Reproduction Instructions
I use exactly the same code as explained in conduit doc :

$api_parameters = array(
      'queryKey' => 'all',
      'constraints' => array(
        'paths' => array(
          $lowerCasePath,
        ),
      ),
      'attachments' => array(
        'content' => 'true',
      ),
    );
    $client = getClient($config); => create client and add token
    $response = $client->callMethodSynchronous('phriction.document.search', $api_parameters); 

I run my script sometimes, i have response sometimes i have error like:

<h1>Error response</h1>
        <p>Error code: 501</p>
        <p>Message: Unsupported method ('params=%7B%22queryKey%22%3A%22all%22%2C%22constraints%22%3A%7B%22paths%22%3A%5B%22active_directory_-_gpos%5C%2F%22%5D%7D%2C%22attachments%22%3A%7B%22conten...</p> 

I put a debug point and run just : $client->callMethodSynchronous(‘phriction.document.search’, $api_parameters); in debug console to be sure i have the same parameter, randomly i have an error.

Phabricator/Arcanist Version
Output from Config > Version Information or arc version.

image

Work in culr mode without error

My local phabricator is commit 64cc4fe9151547a8f872ea8c83b9a6cea22ce023 (phabricator/master)

I can not reproduce this.

$ cat conduit-test.php 
<?php

require_once 'scripts/init/init-script.php';

$paths = array(
  'changelog/',
);

$api_parameters = array(
  'queryKey' => 'all',
  'constraints' => array(
    'paths' => $paths,
  ),
  'attachments' => array(
    'content' => true,
  ),
);

$client = id(new ConduitClient('https://secure.phabricator.com/'))
  ->setConduitToken($argv[1]);

$call_count = 0;

while (true) {
  $t_start = microtime(true);
  $result = $client->callMethodSynchronous(
    'phriction.document.search',
    $api_parameters);
  $t_end = microtime(true);

  $content = idxv(
    $result,
    array(
      'data',
      0,
      'attachments',
      'content',
      'content',
      'raw',
    ));

  $call_count++;

  echo tsprintf(
    "%s\n",
    pht(
      'Success on call %s, got %s result(s) in %sms (content begins: "%s...").',
      new PhutilNumber($call_count),
      phutil_count($result['data']),
      new PhutilNumber(1000 * ($t_end - $t_start)),
      substr($content, 0, 64)));
}
$ php -f conduit-test.php -- $MY_API_TOKEN
Success on call 1, got 1 result(s) in 153ms (content begins: "Phabricator changelogs summary changes to Phabricator over time....").
Success on call 2, got 1 result(s) in 200ms (content begins: "Phabricator changelogs summary changes to Phabricator over time....").
Success on call 3, got 1 result(s) in 120ms (content begins: "Phabricator changelogs summary changes to Phabricator over time....").
Success on call 4, got 1 result(s) in 157ms (content begins: "Phabricator changelogs summary changes to Phabricator over time....").
Success on call 5, got 1 result(s) in 115ms (content begins: "Phabricator changelogs summary changes to Phabricator over time....").
<...snip...>
Success on call 159, got 1 result(s) in 118ms (content begins: "Phabricator changelogs summary changes to Phabricator over time....").
Success on call 160, got 1 result(s) in 147ms (content begins: "Phabricator changelogs summary changes to Phabricator over time....").
Success on call 161, got 1 result(s) in 86ms (content begins: "Phabricator changelogs summary changes to Phabricator over time....").
^C
$

Note that the error message you report does not come from Phabricator (Phabricator does not have the string “Unsuported method” anywhere in its codebase). It’s possible this is caused by a misconfigured webserver or load balancer.

On production serveur there’s no error, that should be on development server configuration

thanks

Error found: Fucking proxy :slight_smile:

require_once '../../scripts/init/init-script.php'; Initialize environment variables.
I have http_proxy and https_proxy but script doesn’t take account the “no-proxy”