fix(consent): a malformed consent request is reported, not ignored - #111
Merged
Merged
Conversation
parseTaskConsentRequest returned "not-a-task-consent-request" for two
completely different situations: a message not addressed to this handler,
and a genuine consent request whose payload is unusable.
dispatchInbound keys on that reason to decide whether to stay quiet:
if (consent.reason !== "not-a-task-consent-request") { warn; return; }
// Anything else is ignored. <- silent
So a malformed consent request was discarded in total silence -- no
prompt, no log -- and handleInbound's finally then cleared its pending
record. The result is indistinguishable from a message that never
arrived, which is how it presented: arrival logged by #105, then nothing
at all, and a pending-approval badge (#110) that counted zero because the
record was already gone.
Malformed payloads now return "malformed-payload", so the existing warn
path reports them with their detail. The silent reason keeps its single
honest meaning: not addressed to this handler.
The test that pinned the old shared reason now pins the distinction and
the detail, with the reasoning recorded -- it was asserting the exact
behaviour that hid this.
Signed-off-by: Glenn Gore <glenn.g@affinidi.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
parseTaskConsentRequestreturned"not-a-task-consent-request"for two completely different situations:dispatchInboundkeys on that reason to decide whether to stay quiet:So a malformed consent request was discarded in total silence — no prompt, no log — and
handleInbound'sfinallythen cleared its pending record.How this presented
Indistinguishable from a message that never arrived:
[pnm inbound] received … task-consent/request/0.1(#105)refusing task-consent request:handling threw(#108)consent window opened/could not open(#106, #107)finallyhad already cleared the recordThat badge counting zero is what localised it. If the flow were hung in
sendMessage, the record would still be there and the badge would have read one. Zero meantdispatchInboundhad returned — and only one return path produces no log at all.The change
Malformed payloads now return
"malformed-payload", so the existing warn path reports them along with theirdetail."not-a-task-consent-request"keeps its single honest meaning: not addressed to this handler.The test that pinned the old shared reason now pins the distinction and the detail, with the reasoning recorded — it was asserting the exact behaviour that hid this.
What this does not do
It does not make the request valid. The next run should log
refusing task-consent request: malformed-payload payload is missing required members— and that names the field the VTA is not sending as the plugin expects. Given the payload is minted inconsent_request.rsand validated here, a cross-service mismatch is the likely next finding.Lint clean, 223 tests pass, builds.