hcengineering/platform · error
Unknown method${method}
Error message
Unknown method${method} What it means
The agent requestHandler's switch fell through to default because the incoming method name matched none of the known opNames. The thrown message concatenates the unknown method name. This is a protocol-level mismatch between caller and agent.
Source
Thrown at foundations/net/packages/client/src/agent.ts:104
container.disconnect(client)
await send('ok')
break
}
case opNames.sendContainer: {
const target: ContainerUuid = params[0]
const operation: string = params[1]
const data: any = params[2]
const container = await this.agent.getContainer(target)
if (container === undefined) {
throw new Error('Container not found')
}
await send(await container.request(operation, data, client))
break
}
default:
throw new Error('Unknown method' + method)
}
}
async helloHandler (clientId: ClientUuid): Promise<void> {
console.log(`Client ${clientId} connected`)
}
async closeHandler (client: ClientUuid): Promise<void> {
console.log(`Client ${client} timed out`)
}
}
/**
* An routed connection to a container via agent.
*/
export class RoutedNetworkAgentConnectionImpl<ClientT extends string = ClientId> {
private readonly client: BackRPCClient<ClientT>
View on GitHub (pinned to 63e28dc964)
Solutions
- Use the exported opNames constants instead of raw strings for method names
- Align client and agent package versions so both support the operation
- Log the method value in the error and fix the misspelling
- Add client-side validation of allowed methods before sending
Example fix
// before
await client.request('sendcontaner', params)
// after
import { opNames } from '@evil-corp/net-client'
await client.request(opNames.sendContainer, params) Defensive patterns
Strategy: validation
Validate before calling
const allowed = Object.values(opNames) as string[]
if (!allowed.includes(method)) {
throw new Error(`Unsupported method: ${method}`)
} Type guard
function isKnownOp(method: string): method is typeof opNames[keyof typeof opNames] {
return (Object.values(opNames) as string[]).includes(method)
} Try / catch
try {
await client.request(method, params)
} catch (e) {
if (e instanceof Error && e.message.startsWith('Unknown method')) {
console.error(`Op ${method} not supported by this agent build; check versions`)
} else { throw e }
} Prevention
- Always use opNames constants, never raw strings
- Keep client and agent package versions in sync
- Validate method names at call sites
- Add protocol version handshake checks
When it happens
Trigger: Calling client.request with a method string not in opNames (typo, wrong casing, method from a newer/older protocol version, or an empty method).
Common situations: Client and agent versions out of sync after an upgrade adding new ops; hand-written method names instead of the opNames constants; typos like 'SendContainer' vs 'sendContainer'.
Related errors
- Unknown method
- Unknown method${method}
- platform.status.BadRequest
- INVALID_PROTOCOL
- Unknown message format:
AI-assisted analysis of hcengineering/platform@63e28dc964 (2026-08-29).
Data as JSON: /api/errors/a355851676903cbd.
Report an issue: GitHub.