StructError: Expected the value to satisfy a union of `type | type`, but received: [object Object]

hi, my code like this:

const xsysAccount = getPDA(program, SYS_ACCOUNT_SEEDS)

return program.account.sysAccount.fetchAndContext(xsysAccount)
.then((xdata) => {
    console.log(`sysAccount: `,

    return true
.catch((xerr) => {
    console.log(`callGetData fail: `, xerr)

    throw xerr

when run it, it throw a exception, the exception is:

StructError: Expected the value to satisfy a union of type | type, but received: [object Object]
at validate (/Users/dj106/bdg2021/code/solCoin/anchor/sol-coin-anchor/node_modules/@solana/web3.js/node_modules/superstruct/src/struct.ts:184:19)
at Object.create (/Users/dj106/bdg2021/code/solCoin/anchor/sol-coin-anchor/node_modules/@solana/web3.js/node_modules/superstruct/src/struct.ts:135:18)
at Connection.getAccountInfoAndContext (/Users/dj106/bdg2021/code/solCoin/anchor/sol-coin-anchor/node_modules/@solana/web3.js/src/connection.ts:3478:17)
at processTicksAndRejections (node:internal/process/task_queues:95:5)
at AccountClient.getAccountInfoAndContext (/Users/dj106/bdg2021/code/solCoin/anchor/sol-coin-anchor/node_modules/@coral-xyz/anchor/src/program/namespace/account.ts:412:12)
at AccountClient.fetchNullableAndContext (/Users/dj106/bdg2021/code/solCoin/anchor/sol-coin-anchor/node_modules/@coral-xyz/anchor/src/program/namespace/account.ts:156:25)
at AccountClient.fetchAndContext (/Users/dj106/bdg2021/code/solCoin/anchor/sol-coin-anchor/node_modules/@coral-xyz/anchor/src/program/namespace/account.ts:194:31) {
value: {
jsonrpc: ‘2.0’,
result: { context: [Object], value: [Object] },
id: 1
type: ‘union’,
refinement: undefined,
key: undefined,
path: ,
branch: [ { jsonrpc: ‘2.0’, result: [Object], id: 1 } ],
failures: [Function (anonymous)]

but before i use the new endpoint of quicknode now, i was use the devnet endpoint of quicknode, it is great. how can i fix it ? thanks very much.


Hi @Danial_Jiang

Can you please share a little bit more context that what you’re trying to do here with the script?

How to solve this err? Please