You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(sqs): fail-closed for recognised-but-unresolved partition keys
Round 2 Codex P1 on PR #715: when a partition resolver is
installed, an unresolved partitioned-shape key (unknown queue /
out-of-range partition) silently falls through to
engine.GetRoute(routeKey(rawKey)). For !sqs|... keys, routeKey
collapses to !sqs|route|global, so the engine routes the
misconfiguration to the SQS catalog default group instead of
returning a routing error. During partition-map drift / partial
rollout this would silently mis-route HT-FIFO traffic.
Fix
- kv.PartitionResolver gains RecognisesPartitionedKey(key) — a
shape-only predicate. Implementations answer purely on prefix /
structural inspection so the router can use it independently
of the in-memory mapping.
- ShardRouter.ResolveGroup: after ResolveGroup returns ok=false,
consult RecognisesPartitionedKey. If the resolver recognises the
shape, return (0, false) WITHOUT engine fallback — the caller
surfaces a routing error. If the shape is not recognised, fall
through to the engine as before.
- adapter.SQSPartitionResolver: implements RecognisesPartitionedKey
via parsePartitionedSQSKey (the same parser ResolveGroup uses).
Nil-receiver and empty-key return false.
Tests
- kv/shard_router_partition_test.go: new
TestShardRouter_FailClosedOnRecognisedButUnresolved — pins that
a recognised-but-unresolved partitioned key returns (0, false)
AND that a non-recognised key still falls through to the engine.
- adapter/sqs_partition_resolver_test.go: new
TestSQSPartitionResolver_RecognisesPartitionedKey covers 8
shape cases (data/vis/byage families with known + unknown
queues, OOR partition, legacy SQS, queue meta, non-SQS, empty,
nil). New TestSQSPartitionResolver_RecognisesPartitionedKey_NilReceiver
pins the typed-nil-safe branch.
- Renamed and expanded
TestSQSPartitionResolver_UnknownQueueRecognisedButUnresolved /
TestSQSPartitionResolver_OutOfRangePartitionRecognisedButUnresolved
to assert RecognisesPartitionedKey == true, pinning the router-
side fail-closed contract.
- Existing fakePartitionResolver / stubResolver / recordingResolver
test doubles get the new method (the kv-internal tests don't
depend on the adapter resolver).
0 commit comments