Skip to content

GetResponse arm logs "unknown contract key" for own inbox/AFT GET-with-subscribe (follow-up to #288/#204) #308

Description

@iduartgomez

Summary

After #288 (PR #307) switched own inbox + AFT-record loads to Get { subscribe: true }, the GetResponse handler logs GetResponse for unknown contract key: <id> for the owner's own contracts. Observed for both alice and bob during the v0.2.2 release e2e smoke run (one key per identity per contract):

[console:alice:error] GetResponse for unknown contract key: 81Mi8CCayjAxQGj49aBxyR4L9mGZNykQVTbSvcTQRTNR
[console:alice:error] GetResponse for unknown contract key: CpgoYwboysh5gEU9VZNZCP62S4A9n1zHxjqekpB56XuJ
[console:bob:error]   GetResponse for unknown contract key: 2TeUu1jjNEfcUWyNSQEhBhRhYE9qSXKXHQ23Gy4FriX3

Severity / impact

Low — log noise, not a functional break. All e2e tests pass (incl. the #288 own-inbox-holding regression, #204, and #81 send/receive), and v0.2.2 shipped + smoke-tested green. Inbox holds, send/receive works. But the spurious ERROR log is misleading during diagnosis and is exactly the failure shape #204 guards against on the other arm.

Root cause

This is the GetResponse-arm analog of #204 (which was fixed only on the UpdateNotification arm).

The GET-with-subscribe for the owner's own inbox / AFT record returns a GetResponse. The GetResponse arm (ui/src/api.rs) recognizes:

  • own inbox via INBOX_TO_ID / contract_identity (~line 2180),
  • own AFT record via token_rec_to_id.remove(&key) (~line 2210),
  • import-fetch / contact-prime / inbox-migration / AFT-migration,
  • else → GetResponse for unknown contract key (ui/src/api.rs:2481).

A GetResponse that arrives before the routing map (token_rec_to_id / INBOX_TO_ID) is populated — or whose key isn't in the map for the consulted instance at that moment — falls through to the "unknown" error. #204 fixed the same race on the UpdateNotification arm by:

  1. registering own-AFT-record keys synchronously in AftRecords::load_all (record_key_for) before the GET, and
  2. adding a race-safe code-hash backstop is_own_aft_record_key (ui/src/api.rs:204) used at ui/src/api.rs:2642.

The GetResponse arm has the synchronous registration (from the same #204 change) but not the code-hash backstop, so a pre-registration GetResponse echo still logs as unknown.

Proposed fix

Mirror the #204 backstop on the GetResponse arm: before logging "unknown contract key" at ui/src/api.rs:2481, check is_own_aft_record_key(&key) (and an analogous own-inbox code-hash check via INBOX_CODE_HASH + LEGACY_INBOX_CODE_HASHES) and debug!-drop instead of error!. The state is already applied through the normal own-inbox/own-AFT branches when the key is registered; the backstop only quiets the pre-registration echo.

Test

Extend the live-node spec (the #288 / #204 area) to assert no GetResponse for unknown contract key for own contracts after identity load — currently only the UpdateNotification variant is guarded.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions