trailofbits/algo · error

Error while stopping server [{response.status_code}: {respon

Error message

Error while stopping server [{response.status_code}: {response.json}]

What it means

This error is raised by the Scaleway compute Ansible module when the HTTP PATCH/POST request to stop (power off) a Scaleway server returns a non-2xx response. The message interpolates the HTTP status code and the parsed JSON body from the Scaleway API so the underlying cause (auth failure, wrong server state, quota, etc.) is embedded in the message.

Source

Thrown at library/scaleway_compute.py:471

        )

    wait_to_complete_state_transition(compute_api=compute_api, server=target_server)

    current_state = fetch_state(compute_api=compute_api, server=target_server)
    if current_state not in ("stopped",):
        compute_api.module.debug("stop_strategy: Server in state: %s" % current_state)

        changed = True

        if compute_api.module.check_mode:
            return changed, {"status": "Server %s would be stopped." % target_server["id"]}

        response = stop_server(compute_api=compute_api, server=target_server)
        compute_api.module.debug(response.json)
        compute_api.module.debug(response.ok)

        if not response.ok:
            msg = f"Error while stopping server [{response.status_code}: {response.json}]"
            compute_api.module.fail_json(msg=msg)

    return changed, target_server


def restart_strategy(compute_api, wished_server):
    compute_api.module.debug("Starting restart strategy")
    changed = False
    query_results = find(compute_api=compute_api, wished_server=wished_server, per_page=1)

    if not query_results:
        changed = True
        if compute_api.module.check_mode:
            return changed, {"status": "A server would be created before being rebooted."}

        target_server = create_server(compute_api=compute_api, server=wished_server)
    else:
        target_server = query_results[0]

View on GitHub (pinned to 20e22a8715)

Solutions

  1. Check the embedded status code and response.json body in the message — it names the exact API failure
  2. Verify the Scaleway auth token (SCW_TOKEN) and that it has Compute instance permissions
  3. Confirm the server name resolves to an existing instance in the configured region/organization
  4. Retry after the server finishes any in-progress state transition (wait a few seconds)
Defensive patterns

Strategy: retry

Try / catch

# In Ansible: use failed_when/retries on the task
- block:
  - name: Stop server
    scaleway_compute:
      state: stopped
      name: "{{ server_name }}"
    register: stop_res
    retries: 3
    delay: 10
  rescue:
  - debug: var=stop_res

Prevention

When it happens

Trigger: Calling the module with state=stopped (stop_strategy) when the Scaleway API 'poweroff' action endpoint returns an error, e.g. 401 invalid token, 404 server UUID not found, or the server is in a transient state that cannot be stopped.

Common situations: Expired or wrong SCW_TOKEN organization token, stale server ID from a previously deleted instance, API rate limiting, or stopping a server already in 'stopping' state.

Related errors


AI-assisted analysis of trailofbits/algo@20e22a8715 (2026-08-28). Data as JSON: /api/errors/a4ce4f1490e3b506. Report an issue: GitHub.