{"record":{"id":"0d469082566de007","repo":"trailofbits/algo","slug":"error-while-restarting-server-that-was-stopped-r","errorCode":null,"errorMessage":"Error while restarting server that was stopped [{response.status_code}: {response.json}].","messagePattern":"Error while restarting server that was stopped \\[(.+?): (.+?)\\]\\.","errorType":"http","errorClass":null,"httpStatus":null,"severity":"error","filePath":"library/scaleway_compute.py","lineNumber":522,"sourceCode":"\n    changed = True\n    if compute_api.module.check_mode:\n        return changed, {\"status\": \"Server %s would be rebooted.\" % target_server[\"id\"]}\n\n    wait_to_complete_state_transition(compute_api=compute_api, server=target_server)\n\n    if fetch_state(compute_api=compute_api, server=target_server) in (\"running\",):\n        response = restart_server(compute_api=compute_api, server=target_server)\n        wait_to_complete_state_transition(compute_api=compute_api, server=target_server)\n        if not response.ok:\n            msg = f\"Error while restarting server that was running [{response.status_code}: {response.json}].\"\n            compute_api.module.fail_json(msg=msg)\n\n    if fetch_state(compute_api=compute_api, server=target_server) in (\"stopped\",):\n        response = restart_server(compute_api=compute_api, server=target_server)\n        wait_to_complete_state_transition(compute_api=compute_api, server=target_server)\n        if not response.ok:\n            msg = f\"Error while restarting server that was stopped [{response.status_code}: {response.json}].\"\n            compute_api.module.fail_json(msg=msg)\n\n    return changed, target_server\n\n\nstate_strategy = {\n    \"present\": present_strategy,\n    \"restarted\": restart_strategy,\n    \"stopped\": stop_strategy,\n    \"running\": running_strategy,\n    \"absent\": absent_strategy,\n}\n\n\ndef find(compute_api, wished_server, per_page=1):\n    compute_api.module.debug(\"Getting inside find\")\n    # Only the name attribute is accepted in the Compute query API\n    response = compute_api.get(\"servers\", params={\"name\": wished_server[\"name\"], \"per_page\": per_page})","sourceCodeStart":504,"sourceCodeEnd":540,"githubUrl":"https://github.com/trailofbits/algo/blob/20e22a8715c198b38c01c1ca62d0953b93587a74/library/scaleway_compute.py#L504-L540","documentation":"Raised when restarting a server that was in 'stopped' state: the module calls the action endpoint (effectively 'power on') and the API returns a non-2xx response. Status code and JSON error body are embedded in the message.","triggerScenarios":"restart_strategy finds fetch_state(...) == 'stopped' and calls restart_server(); the Scaleway API rejects the action (401/403/404 or server in an unstable state).","commonSituations":"Powering on an instance that is mid-deletion, token lacking compute permissions, or API transient failure.","solutions":["Inspect the embedded status code and response.json for the exact cause","Ensure the instance exists and is not being deleted","Retry the play after a short wait; Scaleway state transitions are async"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"- name: Restart stopped server\n  scaleway_compute:\n    state: restarted\n  register: r\n  retries: 3\n  delay: 15\n  until: not r.failed","preventionTips":["Ensure the instance is fully provisioned before restart tasks","Keep tokens scoped and valid for compute actions"],"tags":["scaleway","api-error","ansible","poweron"],"backgroundTag":"cloud-api-request-failed","analyzedSha":"20e22a8715c198b38c01c1ca62d0953b93587a74","analyzedAt":"2026-08-28T13:26:02.752Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}