Page MenuHomePhabricator

Set non-zero "arc conduit-call" exit code in case of error
Closed, WontfixPublic

Description

When conduit call made through arcanist via arc conduit-call some.call-here ends up with error, e.g. following JSON is received

{"error":"ERR-CONDUIT-CALL","errorMessage":"ERR-CONDUIT-CALL: Method 'diffusion.jenkinshook' doesn't define these parameters: 'buildNumbera'.","response":null}

so error isn't empty, we should return non-zero exit code from Arcanist.

Event Timeline

aik099 raised the priority of this task from to Needs Triage.
aik099 updated the task description. (Show Details)
aik099 added a project: Arcanist.
aik099 added a subscriber: aik099.

I agree with this (haven't verified that this is actually the case). I had similar thoughts about the ./scripts/phutil_symbols.php script.

One possible issue is that any scripts which use id(new ExecFuture('arc call-conduit ...'))->resolveJson() will fail with a non-helpful exception message.

chad triaged this task as Low priority.Nov 13 2014, 5:34 PM
epriestley claimed this task.
epriestley added a subscriber: epriestley.

We're trying to make it easy to write unambiguously correct programs.

In general, we assume that your program is parsing output. A return code of 0 means "the output is formatted correctly and parseable, you can continue and parse it", not necessarily that the command produced the desired result.

If we returned nonzero on any error, programs would have no unambiguous way to distinguish between cases like "php is not installed" and "you don't have permission to see that object". To correctly handle errors in a granular way, they'd have to do something like this, accepting parsing ambiguity:

if ($err) {
  $maybe_result = try_to_parse($stdout);
  if ($maybe_result looks like it's probably a valid result, hopefully) {
    handle an application error??;
  }
}

We could use specific error codes to indicate specific conditions, but we can't always control what code we exit with, and codes used by the shell or PHP runtime may be emitted by those layers before we can execute any code. Error codes aren't obvious to a lot of users (many users don't know how to use $?, for example).

In other cases, there's disagreement about what is or isn't an error (e.g., is "no results" an error?).

The implemented semantics are the easiest semantics to use when trying to write a correct, general-case program.

If you're satisfied with a less-correct program, or you have a less-general case where any error can be treated as a failure, it's easy to wrap the call in something which promotes any error response into an exit code.

If we changed the semantics, it would become easier to write a less-general/less-correct program, but harder to write a more-general/more-correct program.