Skip to content

fix(gateway): require usable API_SERVER_KEY to enroll the api_server platform (#36180 salvage) - #70166

Merged
teknium1 merged 1 commit into
mainfrom
salvage/36180-api-cluster
Jul 23, 2026
Merged

fix(gateway): require usable API_SERVER_KEY to enroll the api_server platform (#36180 salvage)#70166
teknium1 merged 1 commit into
mainfrom
salvage/36180-api-cluster

Conversation

@teknium1

Copy link
Copy Markdown
Contributor

Summary

Salvage of #36180 by @arimu1 (earliest PR in the #36111 cluster) — the api_server platform is only enrolled at load time when a usable key exists, closing the "loads, spins the reconnect watcher, and logs errors forever" path.

API_SERVER_ENABLED=true with no (or a weak) key enrolled the platform anyway; the adapter's startup guard then refused every connect() while the watcher retried indefinitely. This gates enrollment with the same strength bar as the startup guard (has_usable_secret, min_length=16), and gives the platform an honest connected-checker.

Changes

  • gateway/config.py: _has_usable_api_server_key() helper; env enrollment gated on it; Platform.API_SERVER connected-checker upgraded from lambda cfg: True to a key check
  • tests/gateway/test_api_server.py, tests/gateway/test_platform_connected_checkers.py: no-key / weak-key / strong-key enrollment tests

Salvage note: the original PR was ~1,700 lines, mostly incidental reformat churn of gateway/config.py; landed here as the 72-line semantic change only. EMAIL/SMS checker additions (scope creep) dropped. Known partial: YAML enabled: true without a key still loads — the connect-time guard covers that path.

Validation

Scenario Result
API_SERVER_ENABLED=true, no key not enrolled
4-char key not enrolled
32-char key enrolled + connected
gateway config/api_server/checker suites 378/378 pass

Authorship preserved (@arimu1). Closes #36180.

Infographic

infographic

…platform at load time

Salvaged from PR #36180 (commits 68dfeb4 and 86f4375 by arimu1),
re-applied onto current main with the incidental black-reformat churn
stripped out (~1,700 lines -> the semantic change + tests).

Previously gateway/config.py enrolled the api_server platform on
`api_server_enabled or api_server_key`, so API_SERVER_ENABLED=true with
no key (or a weak/placeholder key) still loaded the platform: the
adapter is instantiated (ResponseStore/SQLite opened in __init__), the
reconnect watcher spins, and the startup guard refuses at connect() —
logging errors forever. Now the platform is enrolled only when
API_SERVER_KEY passes the same strength bar as the adapter's startup
guard (has_usable_secret, min_length=16), via a shared
_has_usable_api_server_key() helper.

The no-op `lambda cfg: True` connected-checker for API_SERVER is also
replaced with the same key check, so get_connected_platforms() only
reports the platform "up" when it could actually start.

Known limitation (intentionally out of scope): a YAML config with
`platforms.api_server.enabled: true` and no key still loads the
platform; this gate covers the env-override path only.

Dropped from the original PR: EMAIL/SMS checker additions (scope creep
beyond the PR title; absent on current main) and the wholesale black
reformat of gateway/config.py and tests.

Fixes #36111

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

૮ >ﻌ< ა ci review

ran on 8f3c691

all good!

@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/gateway Gateway runner, session dispatch, delivery area/auth Authentication, OAuth, credential pools sweeper:risk-security-boundary Sweeper risk: may affect sandboxing, auth, credentials, or sensitive data labels Jul 23, 2026
@teknium1
teknium1 merged commit 9e4b898 into main Jul 23, 2026
41 checks passed
@teknium1
teknium1 deleted the salvage/36180-api-cluster branch July 23, 2026 18:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/auth Authentication, OAuth, credential pools comp/gateway Gateway runner, session dispatch, delivery P2 Medium — degraded but workaround exists sweeper:risk-security-boundary Sweeper risk: may affect sandboxing, auth, credentials, or sensitive data type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants