Skip to content

Commit bf8f43b

Browse files
committed
fix(scripts): ignore empty auth json
GitHub Actions passes AUTH_JSON as an empty string when the input is unset, which caused config parsing to fail before auth keys were written. Treat blank AUTH_JSON values as absent in the auth merge path so generated provider keys remain valid without requiring a separate JSON payload.
1 parent e9cea29 commit bf8f43b

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

scripts/config.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ def build_auth(
7878
auth_json: str | None,
7979
) -> dict:
8080
auth = generate_auth(anthropic_key, openai_key, gemini_key)
81-
if auth_json is None:
81+
if auth_json is None or not auth_json.strip():
8282
return auth
8383
auth_override = parse_json_object(auth_json, "AUTH_JSON")
8484
return merge_configs(auth, auth_override)
@@ -152,6 +152,8 @@ def main():
152152
openai_key = os.environ.get("OPENAI_API_KEY")
153153
gemini_key = os.environ.get("GEMINI_API_KEY")
154154
auth_json = os.environ.get("AUTH_JSON")
155+
if auth_json is not None and not auth_json.strip():
156+
auth_json = None
155157
config_json = os.environ.get("CONFIG_JSON")
156158
enabled_providers = os.environ.get("ENABLED_PROVIDERS")
157159
disabled_providers = os.environ.get("DISABLED_PROVIDERS")

tests/test_config.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,10 @@ def test_auth_json_empty_object(self):
7474
result = build_auth("ant", None, None, "{}")
7575
assert result == {"anthropic": {"type": "api", "key": "ant"}}
7676

77+
def test_auth_json_empty_string(self):
78+
result = build_auth("ant", None, None, "")
79+
assert result == {"anthropic": {"type": "api", "key": "ant"}}
80+
7781

7882
class TestParseProviderList:
7983
def test_valid_list(self):

0 commit comments

Comments
 (0)