Skip to content
Docs

How-to: Handle unreliable APIs

This guide shows you how to make flows resilient against flaky upstream APIs: what Publicus retries for you automatically, how to bound slow requests with a timeout, and how to keep a flow running (and branch on the failure) instead of hard-failing when an upstream call errors.

The behaviour below applies to outbound HTTP calls made by Rest / Operation, OpenApi / Operation, and the OpenAPI operation pack.

Every outbound API call gets a bounded retry, with no configuration needed on your part:

  • Connection failures (DNS errors, refused connections, dropped sockets) are always retried.
  • 5xx responses are retried only for GET, HEAD, and OPTIONS requests. A POST or PUT that returned a 5xx may already have had side effects upstream, so it is never retried automatically.

By default a failed request is retried 2 times with a short, linearly increasing delay between attempts.

When an upstream host keeps failing, Publicus stops hammering it. Each host has its own circuit breaker:

  1. 5 failures within 120 seconds open the circuit for that host.
  2. While open, requests to that host fail fast for 60 seconds without touching the upstream at all.
  3. After the cooldown, a single probe request decides whether the circuit closes again or re-opens for another cooldown.

You don’t configure the breaker per node; it protects every flow that calls the same host. If you see a node fail almost instantly with a circuit-open error, the host recently failed repeatedly, wait out the cooldown or fix the upstream.

Requests time out after 30 seconds by default. If your upstream is slower (a long-running report endpoint) or you want to fail faster, set Timeout (seconds) (timeoutSeconds), under More settings, on a Rest / Operation or OpenApi / Operation node:

timeoutSeconds: 120

The value covers both connecting and reading the response, and is capped at 300 seconds. Leaving the field blank (or setting 0) uses the 30-second default.

Continue instead of failing: the onError policy

Section titled “Continue instead of failing: the onError policy”

By default an upstream error (4xx, 5xx, connection failure, or open circuit) fails the node and stops the flow. If you want the flow to keep going, open More settings on a Rest / Operation or OpenApi / Operation node and set its On error field to Continue with an error envelope.

With that policy, the node completes and its output becomes a structured error envelope instead of the API response:

{
"error": true,
"upstreamStatus": 503,
"circuitOpen": false,
"message": "Server error: 503 Service Unavailable ..."
}
  • upstreamStatus is the HTTP status, or null for connection failures.
  • circuitOpen is true when the request failed fast because the host’s circuit breaker was open.
  • message is a truncated description of what went wrong.

A node that continues past a refused credential (HTTP 401) is still noticed: its connection reads Failing on the Connections page, and the people who can fix it are told once.

A run report where a Rest Operation that got a 404 completes with an error envelope: error true, upstreamStatus 404, circuitOpen false and the message
A run report where a Rest Operation that got a 404 completes with an error envelope: error true, upstreamStatus 404, circuitOpen false and the message

Downstream nodes can check for the envelope and react. A common pattern is a ConditionalExit guard right after the API node:

condition: $prev->error ?? false
message: Upstream returned {{ $prev->upstreamStatus }}, skipping this run.

The flow continues only when the call succeeded. Or invert it to build a dedicated error-handling branch (log the failure, notify a channel, write a fallback record). See How-to: Conditional logic for the guard patterns. To send a failed node down a path of its own instead, see Handling errors.

  • Any 2xx response succeeds, and the node outputs the raw response body (which may be empty, for example on a 204).

  • A 3xx response is never followed. The node succeeds with a structured result instead:

    { "redirect": 302, "location": "https://example.com/new-url" }

    If you need the redirected resource, call the location URL with a second API node.

  • A 4xx/5xx response is an error: retried where safe (see above), then handled per your onError policy. The response body is included in the error message so you can see what the upstream said.

Point a Rest / Operation node at an endpoint that returns a 500 (most HTTP testing services offer one), set On error, under More settings, to Continue with an error envelope, and run the flow. In Runs, the node completes instead of failing, and its output shows the envelope with upstreamStatus: 500. Run it a few more times in quick succession and you will see the circuit open: runs complete almost instantly with circuitOpen: true.