Skip to content

fix: preserve Uri-Query on OSCORE Echo auto-retry - #398

Open
stoprocent wants to merge 1 commit into
coapjs:masterfrom
stoprocent:fix/echo-retry-uri-query
Open

fix: preserve Uri-Query on OSCORE Echo auto-retry#398
stoprocent wants to merge 1 commit into
coapjs:masterfrom
stoprocent:fix/echo-retry-uri-query

Conversation

@stoprocent

Copy link
Copy Markdown
Contributor

Summary

The client-side Echo auto-retry (RFC 8613 Appendix B.1.2 / RFC 9175) added in #397 skips Uri-Query when copying options onto the retried request, on the assumption it would be reconstructed from retryUrl the same way Uri-Path and Observe are. There is no such reconstruction path for Uri-Query in this library — CoapRequestParams has no query field, so it is only ever set via setOption('Uri-Query', ...) on the original request — meaning the retry silently drops it.

Reported downstream as a real interop bug: a client sends GET /resource?param=value over OSCORE, the server issues a 4.01 Unauthorized + Echo freshness challenge on the first request after a context reset (fresh boot / no persisted replay window), and the auto-retried request arrives without the query parameters — servers that require them then reject the retry with 4.00 Bad Request.

Fix

lib/agent.ts: remove Uri-Query from the option skip-list in the Echo auto-retry path. Only Uri-Path and Observe are actually reconstructed from retryUrl (via url.pathname / url.observe), so those stay skipped; every other option — including Uri-Query — is copied through unchanged, matching a plain PDU-clone-and-add-Echo retry (e.g. coap_pdu_duplicate in libcoap).

Tests

test/oscore.ts: new regression test (client-side Echo auto-retry) using a raw OSCORE fake-server harness (same pattern as the existing "non-OSCORE messages from OSCORE peer" tests) that issues a 4.01 + Echo challenge on the first request and asserts the retried request still carries the original Uri-Query option. Confirmed it fails on the pre-fix code and passes after.

Full suite: 506 passing, 3 pre-existing unrelated multicast failures (network-environment timeouts, untouched by this change).

🤖 Generated with Claude Code

The client-side Echo auto-retry (RFC 8613 Appendix B.1.2 / RFC 9175)
skipped Uri-Query when copying options onto the retried request, on the
assumption it would be reconstructed from retryUrl like Uri-Path and
Observe are. There is no such reconstruction path for Uri-Query in this
library — CoapRequestParams has no `query` field, it is only ever set via
setOption() on the original request — so the retry silently lost it.

GWLB-2727: node-red client dropped Uri-Query when retrying after a
device's 4.01 + Echo freshness challenge, causing the retried GET/DELETE
to fail with 4.00 Bad Request.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant