Skip to content

REQ-6: Graceful Shutdown Handling#669

Open
riz-hossain wants to merge 1 commit intodevfrom
zeuz-REQ-6
Open

REQ-6: Graceful Shutdown Handling#669
riz-hossain wants to merge 1 commit intodevfrom
zeuz-REQ-6

Conversation

@riz-hossain
Copy link
Contributor

ZeuZ Agent

  • Item: REQ-6
  • Type: Requirement

Item Description

Graceful Shutdown Handling

Handle Ctrl+C interruptions and termination signals (such as SIGTERM and SIGKILL) so the node exits cleanly without hanging.

Behavior Requirements

  • Capture termination signals and initiate a controlled shutdown sequence.
  • Stop running tasks safely and release resources before exit.
  • Ensure the process completes shutdown promptly and does not stall.

Parent Requirement

Additional Instructions

Generated by ZeuZ Agent.

server/mobile.py Outdated

Check warning

Code scanning / CodeQL

Information exposure through an exception Medium

Stack trace information
flows to this location and may be exposed to an external user.

Copilot Autofix

AI 1 day ago

In general, to fix this kind of problem you should avoid returning raw exception messages or stack traces to clients. Instead, log the full error details on the server (including stack trace if needed for debugging), and send a generic, non-sensitive message in the HTTP response. This preserves diagnostic usefulness for developers while preventing attackers from learning about internal implementation details.

For this specific case in server/mobile.py, the main change is to modify the except Exception as e: block in is_ios_app_installed so that it no longer returns str(e) to the client. Instead, it should log the exception using the existing logging module that is already imported at the top of the file, and then return a generic error message. Concretely:

  • Use logging.exception(...) (or logging.error(...)) inside the except block to record the error and stack trace on the server.
  • Remove str(e) from the returned JSON, replacing it with a neutral message such as "An internal error occurred while checking installation status." that does not reveal system details.
  • Keep the "installed": False key so that existing client logic relying on that field continues to work; only the content of the "error" field is changed to be generic.
  • All changes are confined to the is_ios_app_installed function (lines 787–808) in server/mobile.py; no new imports or external libraries are required since logging is already imported.
Suggested changeset 1
server/mobile.py

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/server/mobile.py b/server/mobile.py
--- a/server/mobile.py
+++ b/server/mobile.py
@@ -804,5 +804,9 @@
             return {"installed": True}
         
         return {"installed": False}
-    except Exception as e:
-        return {"installed": False, "error": str(e)}
+    except Exception:
+        logging.exception("Failed to check if iOS app is installed for sim_udid=%s, bundle_id=%s", sim_udid, bundle_id)
+        return {
+            "installed": False,
+            "error": "An internal error occurred while checking installation status."
+        }
EOF
@@ -804,5 +804,9 @@
return {"installed": True}

return {"installed": False}
except Exception as e:
return {"installed": False, "error": str(e)}
except Exception:
logging.exception("Failed to check if iOS app is installed for sim_udid=%s, bundle_id=%s", sim_udid, bundle_id)
return {
"installed": False,
"error": "An internal error occurred while checking installation status."
}
Copilot is powered by AI and may make mistakes. Always verify output.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant