{"record":{"id":"54b99730e5027ba3","repo":"trailofbits/algo","slug":"error-while-restarting-server-that-was-running-r","errorCode":null,"errorMessage":"Error while restarting server that was running [{response.status_code}: {response.json}].","messagePattern":"Error while restarting server that was running \\[(.+?): (.+?)\\]\\.","errorType":"http","errorClass":null,"httpStatus":null,"severity":"error","filePath":"library/scaleway_compute.py","lineNumber":515,"sourceCode":"            return changed, {\n                \"status\": \"Server %s attributes would be changed before rebooting it.\" % target_server[\"id\"]\n            }\n\n        target_server = server_change_attributes(\n            compute_api=compute_api, target_server=target_server, wished_server=wished_server\n        )\n\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,","sourceCodeStart":497,"sourceCodeEnd":533,"githubUrl":"https://github.com/trailofbits/algo/blob/20e22a8715c198b38c01c1ca62d0953b93587a74/library/scaleway_compute.py#L497-L533","documentation":"Raised when restarting a Scaleway server that is currently 'running': the module issues an API 'reboot' action and the response is not ok. The status code and JSON body of the failed reboot call are included in the message.","triggerScenarios":"restart_strategy detects fetch_state(...) == 'running' and calls restart_server(); the Scaleway reboot endpoint returns 4xx/5xx (bad token, server locked in a task, 404).","commonSituations":"Rebooting an instance that has a pending blocking task, insufficient permissions on the token, or an instance that was deleted between the state check and the reboot call.","solutions":["Read the status code/JSON in the message to identify the API reason","Retry after waiting for the server's current task to finish (state transitions are asynchronous)","Verify token permissions and that the instance still exists in the Scaleway console"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"- name: Restart\n  scaleway_compute:\n    state: restarted\n  register: r\n  retries: 3\n  delay: 15\n  until: not r.failed","preventionTips":["Wait for async state transitions before rebooting","Log the embedded status code to distinguish auth vs state errors"],"tags":["scaleway","api-error","ansible","reboot"],"backgroundTag":"cloud-api-request-failed","analyzedSha":"20e22a8715c198b38c01c1ca62d0953b93587a74","analyzedAt":"2026-08-28T13:26:02.752Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}