Ruby SDK

Errors

The exception classes the gem raises, what each carries and when it is raised.

Every exception the gem defines inherits from Scute::Error (a StandardError).

begin  scute.users.merge(user_id, from: old_id)rescue Scute::APIError => e  e.status  # 409  e.code    # "already_merged"  e.body    # the API's answer, parsedrescue Scute::ConnectionError  # Scute could not be reachedend

Classes#

ClassRaised whenAttributes
Scute::APIErrorScute answered 4xx or 5xx.status, code (the API's error_code), body
Scute::ConnectionErrorScute could not be reached: connection refused or reset, host unreachable, timeout, DNS, TLS. Raised after the retries for idempotent calls.none
Scute::ConfigurationErrorSomething needed for the call is missing: the app id, the secret key, or a task token for a harness run.none
Scute::InvalidTokentokens.verify refused the token.reason
Scute::Unauthenticatedscute_authenticate! found no valid session, or scute_authorize! ran with nobody signed in. Same class as Scute::Authentication::Unauthenticated.reason
Scute::Forbiddenscute_authorize! got an answer that is not a plain allow. Same class as Scute::Authorization::Forbidden.decision

ArgumentError (from Ruby) is raised for bad input before any request: a client_ip that is not one address, more than 100 checks in check_batch, start_step_up without a permission or method, a decide_request verdict other than :approve or :deny.

Scute::APIError#

The message is the API's error, then its say, then "Scute answered <status>". code is nil when the answer has no error_code.

Codes the SDK itself reacts to:

CodeWhere
already_mergedusers.merge on an account merged before.
task_closed (status 409)A harness run whose task is over. Raised by the SDK; start a new run.
invalid_task_token (status 401)A task token Scute says is dead before its expiry (revoked, completed, agent suspended). The run closes for good.
not_verified (status 409)run.complete_verification before the verification completed. Raised by the SDK.

Scute::InvalidToken reasons#

reasonMeaning
:missingNo token.
:malformedNot a JWT, or no exp.
:algorithmNot RS256 (including alg: none).
:signatureThe signature matches none of the app's keys.
:expiredexp is more than 30 seconds in the past.
:wrong_appThe token is for another app.
:not_a_userNot a user's session (an M2M token, or no uuid).
:revokedremote: true and Scute says the session has ended.

Scute::Unauthenticated#reason carries the same symbol. Its default message is "Sign in first" with reason :missing.

Scute::Forbidden#

The message is decision.explanation, or "Not allowed (<reason>)" when there is none. decision is a Scute::Authz::Decision:

rescue_from Scute::Forbidden do |e|  if e.decision.step_up? then render json: { step_up: e.decision.step_up }, status: :forbidden  elsif e.decision.needs_approval? then render json: { approval: true }, status: :forbidden  else render json: { error: e.message }, status: :forbidden  endend

In a harness run#

Guards do not raise into your tool code. A call that may not run returns a message for the model instead (from run.wrap, or { error: ... } from the RubyLLM adapter). A guard that raises counts as deny.