From fe0decdd9d2f498acd96b76655e3a1a5411d6c8d Mon Sep 17 00:00:00 2001 From: Oluwatosin Date: Wed, 9 Sep 2026 15:46:48 +0400 Subject: [PATCH] velociraptor: guard auth() against get_file() returning None When the worker cannot reach the Shuffle files API (distributed / multi-org runtimes), get_file() returns None and auth() crashed with "'NoneType' object is not subscriptable". Guard it, fall back to treating api_config as the credential contents, and raise a clear error otherwise. --- velociraptor/1.0.0/src/app.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/velociraptor/1.0.0/src/app.py b/velociraptor/1.0.0/src/app.py index 0e8bed87..6354f44f 100644 --- a/velociraptor/1.0.0/src/app.py +++ b/velociraptor/1.0.0/src/app.py @@ -23,7 +23,20 @@ def __init__(self, redis, logger, console_logger=None): super().__init__(redis, logger, console_logger) def auth(self, api_config): - credfile = self.get_file(api_config)["data"] + # get_file() returns None when the worker cannot reach the Shuffle + # files API (e.g. distributed/org runtimes). Guard it, and fall back to + # treating api_config as the credential contents themselves, so the + # config can also be supplied inline. Raise a clear error otherwise + # instead of the opaque "'NoneType' object is not subscriptable". + _f = self.get_file(api_config) + credfile = _f["data"] if isinstance(_f, dict) and _f.get("data") else api_config + if not credfile: + raise ValueError( + "Velociraptor: could not load the API credential. get_file() " + "returned no data - the worker may be unable to reach the " + "Shuffle files API. Provide the api.config.yaml contents in the " + "authentication field." + ) config = yaml.load(credfile, Loader=yaml.FullLoader) creds = grpc.ssl_channel_credentials( root_certificates=config["ca_certificate"].encode("utf8"),