Skip to content

AI agent skill that researches any topic across Reddit, X, YouTube, HN, Polymarket, and the web - then synthesizes a grounded summary

fix: surface keychain alias config errors

Trevin Chow25b86de81cad
diff --git a/CONFIGURATION.md b/CONFIGURATION.md
index 574806db..0d5956ad 100644
--- a/CONFIGURATION.md
+++ b/CONFIGURATION.md
@@ -217,6 +217,10 @@ The alias value contains no secret material; it is safe to keep in `.env` as
configuration. The secret itself remains in its original Keychain item and is
read directly by the engine process.
+Write `LAST30DAYS_KEYCHAIN_ALIASES` as a single-line JSON value in `.env`.
+Multiline JSON formatting is not supported because `.env` files are parsed
+line-by-line.
+
### Bluesky app-password format and search host
`BSKY_APP_PASSWORD` should be a 19-char app password in `xxxx-xxxx-xxxx-xxxx` format (lowercase alphanumeric, three hyphens). Generate one at <https://bsky.app/settings/app-passwords>. The AT Protocol's `createSession` endpoint also accepts your main account login password, but that's bad hygiene — main passwords have no scope (an app password can be limited to non-DM access) and can't be revoked individually.
diff --git a/skills/last30days/scripts/lib/env.py b/skills/last30days/scripts/lib/env.py
index ac705aa8..d81558d4 100644
--- a/skills/last30days/scripts/lib/env.py
+++ b/skills/last30days/scripts/lib/env.py
@@ -136,14 +136,19 @@ def _parse_keychain_aliases(raw: str | None) -> dict[str, list[dict[str, str]]]:
{"XAI_API_KEY": {"service": "existing-xai-api-key", "account": "keychain-user"}}
{"XAI_API_KEY": [{"service": "primary"}, {"service": "fallback"}]}
- Invalid entries are ignored silently so a typo never blocks canonical
- `last30days-<KEY>` lookups.
+ Invalid entries are ignored so a typo never blocks canonical
+ `last30days-<KEY>` lookups; malformed JSON emits a warning.
"""
if not raw:
return {}
try:
parsed = json.loads(raw)
- except json.JSONDecodeError:
+ except json.JSONDecodeError as exc:
+ sys.stderr.write(
+ f"[last30days] WARNING: {KEYCHAIN_ALIASES_ENV} is not valid JSON; "
+ f"ignoring Keychain aliases while keeping canonical lookups enabled: {exc}\n"
+ )
+ sys.stderr.flush()
return {}
if not isinstance(parsed, dict):
return {}
diff --git a/tests/test_env_keychain.py b/tests/test_env_keychain.py
index 08990489..27717d13 100644
--- a/tests/test_env_keychain.py
+++ b/tests/test_env_keychain.py
@@ -62,9 +62,14 @@ def test_parse_keychain_aliases_accepts_ordered_fallback_list():
}
-def test_parse_keychain_aliases_ignores_invalid_json_and_unknown_keys():
+def test_parse_keychain_aliases_warns_on_invalid_json_and_ignores_unknown_keys(capsys):
assert env._parse_keychain_aliases("not json") == {}
+ warning = capsys.readouterr().err
+ assert "LAST30DAYS_KEYCHAIN_ALIASES is not valid JSON" in warning
+ assert "canonical lookups enabled" in warning
+
assert env._parse_keychain_aliases('{"NOT_A_KEY":"secret-service"}') == {}
+ assert capsys.readouterr().err == ""
def test_load_keychain_loads_present_keys_skips_missing():