Skip to content

SWM write via node-level API token crashes with TypeError (toLowerCase on undefined) #787

Description

@Niks988

SWM write via node-level API token crashes with TypeError (toLowerCase on undefined)

Description/Context

Any /api/shared-memory/write call using a node-level auth token returns HTTP 500 with Cannot read properties of undefined (reading 'toLowerCase'). This blocks the write-to-publish-to-on-chain flow via the API.

Steps to reproduce

  1. Deploy any rc.12 node (Oxigraph or Blazegraph, any network).

  2. Grab the node-level auth token:

TOKEN=$(cat /root/dkg-data/auth.token)
  1. Create a context graph:
curl -s -X POST -H "Authorization: Bearer $TOKEN" \
     -H "Content-Type: application/json" \
     -d '{"id": "test-cg", "name": "Test CG"}' \
     http://127.0.0.1:9200/api/context-graph/create | python3 -m json.tool

This succeeds — returns did:dkg:context-graph:test-cg.

  1. Write triples to shared memory:
curl -s -X POST -H "Authorization: Bearer $TOKEN" \
     -H "Content-Type: application/json" \
     -d '{"contextGraphId": "test-cg", "quads": ["<http://example.org/s> <http://example.org/p> \"test\" ."]}' \
     http://127.0.0.1:9200/api/shared-memory/write | python3 -m json.tool

Returns {"error":"Cannot read properties of undefined (reading 'toLowerCase')"}.

  1. Passing an explicit agentAddress in the body does not help — same error:
curl -s -X POST -H "Authorization: Bearer $TOKEN" \
     -H "Content-Type: application/json" \
     -d '{"contextGraphId": "test-cg", "agentAddress": "0x<your-agent-address>", "quads": ["<http://example.org/s> <http://example.org/p> \"test\" ."]}' \
     http://127.0.0.1:9200/api/shared-memory/write | python3 -m json.tool

Same {"error":"Cannot read properties of undefined (reading 'toLowerCase')"}.

  1. Check the daemon log:
tail -20 /root/dkg-data/daemon.log

Shows Sharing 1 quads to SWM for context graph test-cg but not Writing N quads to shared memory ..., confirming the crash happens in the agent layer before the publisher or store is reached.

Root cause

dkg-agent.ts line 5559, inside getWorkspaceGossipSigningAgent():

if (defaultAddress && record.agentAddress.toLowerCase() === defaultAddress) {

When iterating localAgents, a record with a missing/undefined agentAddress causes the crash. This function is called from resolveWorkspaceGossipSigningAgent() (line 7551) during every share() call, including localOnly: true.

Scope

All rc.12 nodes, Oxigraph and Blazegraph alike. Not store-specific. Confirmed by exhaustive .toLowerCase() audit across packages/agent, packages/publisher, packages/storage, and packages/cli.

Found during

RC.12 Blazegraph testnet validation on Ubuntu 24.04 with release/rc.12 branch.

Severity

High — completely blocks the SWM write path for any node-level API consumer.

Metadata

Metadata

Assignees

No one assigned

    Labels

    pre-mainnetMust land before mainnet launchpriority:mediumReal defect or gap; fix planned but not release-gating on its own

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions