From 34148f9f443988b2d44eae37859a9c3c805d219f Mon Sep 17 00:00:00 2001 From: fang Date: Wed, 13 Sep 2023 13:56:48 +0200 Subject: [PATCH] eyre: allow PUTting empty channel-request list Previously, we would reject this with a 400 error. Considering the request body is expected to contain "array of requests" and that arrays may be empty, we really should not be rejecting the requests. Prior to 156ca21472, sending the empty array would have been convenient for channel creation. Empty arrays getting rejected forced clients to inject a faux poke (commonly hi-ing oneself). With that recent change, the most common case for wanting to PUT the empty list of requests is largely obsolete, but one can still imagine it being useful for clients that want to keep their channel alive without necessarily being connected to it. This also implements sloppier clients from running into 400 responses when they submit an empty "command queue" for whatever. Regardless, there seems to be no clear reason why the empty request list _shouldn't_ be accepted and processed as normal. We add a small test to ensure eyre accepts this. --- pkg/arvo/sys/vane/eyre.hoon | 5 ----- tests/sys/vane/eyre.hoon | 12 ++++++++++++ 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/pkg/arvo/sys/vane/eyre.hoon b/pkg/arvo/sys/vane/eyre.hoon index 09d04a30f..e52da9ecf 100644 --- a/pkg/arvo/sys/vane/eyre.hoon +++ b/pkg/arvo/sys/vane/eyre.hoon @@ -2372,11 +2372,6 @@ ?: ?=(%| -.maybe-requests) %^ return-static-data-on-duct 400 'text/html' (error-page 400 & url.request (trip p.maybe-requests)) - :: while weird, the request list could be empty - :: - ?: =(~ p.maybe-requests) - %^ return-static-data-on-duct 400 'text/html' - (error-page 400 %.y url.request "empty list of actions") :: check for the existence of the channel-id :: :: if we have no session, create a new one set to expire in diff --git a/tests/sys/vane/eyre.hoon b/tests/sys/vane/eyre.hoon index 4e59d5dd7..db6e35a98 100644 --- a/tests/sys/vane/eyre.hoon +++ b/tests/sys/vane/eyre.hoon @@ -757,6 +757,18 @@ =/ mov-2 (ex-channel-response ~) (expect-moves mos mov-1 mov-2 ~) :: +++ test-channel-put-zero-requests + %- eval-mare + =/ m (mare ,~) + ;< ~ bind:m perform-init-start-channel-2 + ;< ~ bind:m (wait ~m1) + ;< mos=(list move) bind:m + (put '/~/channel/0123456789abcdef' cookie '[]') + =/ mov-1 ex-204 + =/ mov-2 (ex-rest /channel/timeout/'0123456789abcdef' ~1111.1.2..12.00.00) + =/ mov-3 (ex-wait /channel/timeout/'0123456789abcdef' ~1111.1.2..12.01.00) + (expect-moves mos mov-1 mov-2 mov-3 ~) +:: ++ test-channel-results-before-open %- eval-mare =/ m (mare ,~)