[Bug] Query entities implementing same interface: Failed to get entities from store: operator does not exist: text = bytea

未关闭
#5,443 2 条评论 1 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
25/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
停滞
技术栈
graphql, postgresql, rust

调研方向

首先,针对报告的 schema 重现 issue 中的三个 GraphQL 查询,并检查错误日志中生成的 PostgreSQL 查询和类型绑定。跟踪通过 store query path 的 interface-reference 遍历。完成的标准是:两个嵌套查询在不出现 text = bytea 错误的情况下返回预期的 interface 实体,并且针对这种 schema 形状具有覆盖。

由索引模型根据 Issue 内容生成。

描述

bug Stale
Bug report

Current graphql schema looks like this

interface IConfigForProcesses {
    id: ID!
}

type MajorityVotingConfig implements IConfigForProcesses @entity {
    id: ID!

    # flat fields with values
}

type MultiprocessConfig implements IConfigForProcesses @entity {
    id: ID!
    
    # flat fields with values
}

type NominationConfig implements IConfigForProcesses @entity {
    id: ID!

    # flat fields with values
}

type SignatureCollectionConfig implements IConfigForProcesses @entity {
    id: ID!

    # flat fields with values
}

type PetitionCreationConfig implements IConfigForProcesses @entity {
    id: ID!

    # flat fields with values
}

type ElectionActionConfig implements IConfigForProcesses @entity {
    id: ID!

    # flat fields with values
}

type ProcessSpawner implements IAddressable & ITimestamp @entity(immutable: true) {
    id: Bytes!

    staticConfig: IConfigForProcesses

    # flat fields with values
}

type Structure @entity {
    id: Bytes!

    processes: [StructureProcessSpawner!]! @derivedFrom(field: "structure")
}

type StructureProcessSpawner @entity {
    id: Bytes!
    title: String!
    structure: Structure!
    processSpawner: ProcessSpawner!
    timestamp: BigInt!
}

with this kind of structure I've tried three queries

query WORKING_PROCESS_SPAWNERS {
      processSpawners {
        staticConfig {
          id
        }
      }
}
query ERROR_INTERMEDIATE_OBJ_STRUCTURE_PROCESS {
  structureProcessSpawners {
    processSpawner {
      staticConfig {
        id
      }
    }
  }
}
query QUERY_RESULTING_IN_ERROR {
  structures {
    processes {
      processSpawner {
        staticConfig {
          id
        }
      }
    }
  }
}

First query return correct data, but the last two result in error, bubbling up from Postgres.

It does not error when ProcessSpawner.staticConfig is Bytes instead of interface reference, but it defeats the point of using interfaces.

Do you have any ideas why it can be occurring?

From what I've tried already:

  • changing id from Bytes to ID and back
  • changing running graph-node version from v0.35.0 to v0.34.1
  • updating ts packages to the latest versions (@graphprotocol/graph-cli to 0.73.0, 0.35.1)
  • cherry-picking starting from the last working commit didn't show any meaningful changes (please contact for more info, cannot share full code publicly)
Tested environments

Local setup:

  • OS: mac os
  • graph-node in docker container: v0.35.0 and v0.34.1

Remote setup:

  • OS: Debian 12
  • graph-node in docker container: v0.35.0
Relevant log output
{
  "errors": [
    {
      "message": "Failed to get entities from store: operator does not exist: text = bytea, query = /* controller='filter',application='sgd11',route='d701c3827c55de44-6dc8c4ef99f8cc6a',action='812812' */\nwith matches as (select c.* from unnest($1) as q(id)\n cross join lateral (select 'MajorityVotingConfig' as entity, c.id, c.vid, p.id::text as g$parent_id\n/* child_type_d */ from rows from (unnest($2), unnest($3)) as p(id, child_id), \"sgd11\".\"majority_voting_config\" c where c.block_range @> $4 and q.id = p.id and c.id = any($5) and c.id = p.child_id\nunion all\nselect 'MultiprocessConfig' as entity, c.id, c.vid, p.id::text as g$parent_id\n/* child_type_d */ from rows from (unnest($6), unnest($7)) as p(id, child_id), \"sgd11\".\"multiprocess_config\" c where c.block_range @> $8 and q.id = p.id and c.id = any($9) and c.id = p.child_id\nunion all\nselect 'NominationConfig' as entity, c.id, c.vid, p.id::text as g$parent_id\n/* child_type_d */ from rows from (unnest($10), unnest($11)) as p(id, child_id), \"sgd11\".\"nomination_config\" c where c.block_range @> $12 and q.id = p.id and c.id = any($13) and c.id = p.child_id\nunion all\nselect 'SignatureCollectionConfig' as entity, c.id, c.vid, p.id::text as g$parent_id\n/* child_type_d */ from rows from (unnest($14), unnest($15)) as p(id, child_id), \"sgd11\".\"signature_collection_config\" c where c.block_range @> $16 and q.id = p.id and c.id = any($17) and c.id = p.child_id\nunion all\nselect 'PetitionCreationConfig' as entity, c.id, c.vid, p.id::text as g$parent_id\n/* child_type_d */ from rows from (unnest($18), unnest($19)) as p(id, child_id), \"sgd11\".\"petition_creation_config\" c where c.block_range @> $20 and q.id = p.id and c.id = any($21) and c.id = p.child_id\nunion all\nselect 'ElectionActionConfig' as entity, c.id, c.vid, p.id::text as g$parent_id\n/* child_type_d */ from rows from (unnest($22), unnest($23)) as p(id, child_id), \"sgd11\".\"election_action_config\" c where c.block_range @> $24 and q.id = p.id and c.id = any($25) and c.id = p.child_id\n\n limit 100) c)\nselect m.*, to_jsonb(\"c\".*)|| jsonb_build_object('g$parent_id', m.g$parent_id) as data\n  from \"sgd11\".\"majority_voting_config\" c, matches m\n where c.vid = m.vid and m.entity = 'MajorityVotingConfig'\nunion all\nselect m.*, to_jsonb(\"c\".*)|| jsonb_build_object('g$parent_id', m.g$parent_id) as data\n  from \"sgd11\".\"multiprocess_config\" c, matches m\n where c.vid = m.vid and m.entity = 'MultiprocessConfig'\nunion all\nselect m.*, to_jsonb(\"c\".*)|| jsonb_build_object('g$parent_id', m.g$parent_id) as data\n  from \"sgd11\".\"nomination_config\" c, matches m\n where c.vid = m.vid and m.entity = 'NominationConfig'\nunion all\nselect m.*, to_jsonb(\"c\".*)|| jsonb_build_object('g$parent_id', m.g$parent_id) as data\n  from \"sgd11\".\"signature_collection_config\" c, matches m\n where c.vid = m.vid and m.entity = 'SignatureCollectionConfig'\nunion all\nselect m.*, to_jsonb(\"c\".*)|| jsonb_build_object('g$parent_id', m.g$parent_id) as data\n  from \"sgd11\".\"petition_creation_config\" c, matches m\n where c.vid = m.vid and m.entity = 'PetitionCreationConfig'\nunion all\nselect m.*, to_jsonb(\"c\".*)|| jsonb_build_object('g$parent_id', m.g$parent_id) as data\n  from \"sgd11\".\"election_action_config\" c, matches m\n where c.vid = m.vid and m.entity = 'ElectionActionConfig'\n  -- binds: [[], [], [], 812812, [], [], [], 812812, [], [], [], 812812, [], [], [], 812812, [], [], [], 812812, [], [], [], 812812, []]"
    }
  ]
}
IPFS hash

No response

Subgraph name or link to explorer

No response

Some information to help us out
  • Tick this box if this bug is caused by a regression found in the latest release.
  • Tick this box if this bug is specific to the hosted service.
  • I have searched the issue tracker to make sure this issue is not a duplicate.
OS information

Other (please specify in your bug report)

主要语言
Rust
星标
3.2k
派生
1.1k
平均合并
4 天 1 小时
30 天内合并 PR
1

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

graphprotocol/graph-node 的其他 Issue

查看 graphprotocol/graph-node 的全部 Issue

相似的 Issue

更多 Rust Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。