Skip to content

The agent that grows with you

fix(gateway): only an admitted-send retry drops to info

Tekniumc60792b44f27
diff --git a/gateway/session_controls.py b/gateway/session_controls.py
index 9f740c70553..733216380ef 100644
--- a/gateway/session_controls.py
+++ b/gateway/session_controls.py
@@ -52,8 +52,9 @@ def _log_refusal(profile, method, exc: RuntimeStoreError) -> None:
A refusal that names the check that fired is a launch diagnostic (warning). A bare reason code is
the client's own state: ``permission_denied`` on a submit, ``not_found``, ``session_busy`` are
routine, and a retrying client must not be able to flood the gateway log, so those stay at debug
- where they were silent before. ``field=request_id`` is a client's explicit retry of a send already
- admitted (the dedupe working), so it is info: expected, never in errors.log. The shape follows the
+ where they were silent before. ``admission_conflict field=request_id`` is a client's explicit retry of
+ a send already admitted (the dedupe working), so it is info: expected, never in errors.log. Any other
+ reason tagged ``field=request_id`` (session.create's ``invalid_params``) is a real refusal: warning. The shape follows the
gateway's own refusal log lines (``gateway/run_notifications.py``): what was refused, for which
profile, and why."""
line = '%s refused for profile=%s: %s%s%s'
@@ -63,7 +64,7 @@ def _log_refusal(profile, method, exc: RuntimeStoreError) -> None:
field = getattr(exc, 'field', None)
if exc.reason == 'session_busy' or not (field or getattr(exc, 'detail', None)):
logger.debug(line, *args)
- elif field == 'request_id':
+ elif field == 'request_id' and exc.reason == 'admission_conflict':
logger.info(line, *args)
else:
logger.warning(line, *args)
diff --git a/tests/gateway/test_submission_row_identity.py b/tests/gateway/test_submission_row_identity.py
index bf74e21f724..d4558a45851 100644
--- a/tests/gateway/test_submission_row_identity.py
+++ b/tests/gateway/test_submission_row_identity.py
@@ -66,3 +66,23 @@ async def test_a_retry_of_an_admitted_id_is_an_info_line_never_an_error(tmp_path
assert reply['error']['data']['field'] == 'request_id', reply
refusals = [r for r in caplog.records if 'refused for profile' in r.getMessage()]
assert [r.levelname for r in refusals] == ['INFO'], [(r.levelname, r.getMessage()) for r in refusals]
+
+
+async def test_a_malformed_create_request_id_stays_a_warning(tmp_path, monkeypatch, caplog):
+ """Only the admitted-send retry is lowered: session.create's ``invalid_params field=request_id`` still reaches errors.log."""
+ from gateway.session_controls import AuthorityConnection
+
+ async def answer(event):
+ return 'ok'
+ authority = await _authority(tmp_path, monkeypatch, answer)
+ connection = AuthorityConnection(authority, object(), {'user_id': 'owner'})
+ try:
+ with caplog.at_level('DEBUG', logger='gateway.session_controls'):
+ reply = await connection.dispatch({'id': 1, 'method': 'session.create', 'params': {'request_id': 'x' * 300}})
+ finally:
+ await connection.close()
+
+ assert reply['error']['data']['field'] == 'request_id', reply
+ refusals = [r for r in caplog.records if 'refused for profile' in r.getMessage()]
+ assert [r.levelname for r in refusals] == ['WARNING'], [(r.levelname, r.getMessage()) for r in refusals]