#6170·nebula

An edge variable shared across two `MATCH` clauses wrongly equates two distinct edges whose string VIDs concatenate to the same value

Author: ting668Created Sep 20, 2026Updated Sep 21, 2026
Labelstype/bugseverity/noneaffects/none

Reporter: ting668

Environment

  • OS: Linux (WSL2 host); NebulaGraph services inside Docker containers
  • Docker images: vesoft/nebula-graphd:v3.8.0, vesoft/nebula-metad:v3.8.0, vesoft/nebula-storaged:v3.8.0 (Docker Compose)
  • NebulaGraph Version: 3.8.0 (Git 7458486)

Description

While testing NebulaGraph using an intuitive approach inspired by attribute constraints, I found that when the same edge variable is used in two MATCH clauses, two distinct edges whose string VIDs concatenate to the same value are joined as if they were the same edge.

In the example below the graph contains the two distinct knows edges "A"->"BC" and "AB"->"C" (both rank 0). The first MATCH pins e to the edge "A"->"BC" and the second requires the same variable e to be the edge "AB"->"C". Since one variable cannot denote two different edges, the query has no solution; NebulaGraph returns one row, joining the two edges on a key in which "A"+"BC" and "AB"+"C" are indistinguishable.

How to Reproduce and Expected Behavior

Note: The queries below are a minimized, simplified example reproducing the bug.

Buggy query (with the minimal setup below):

ngql
CREATE SPACE repro(partition_num=1,replica_factor=1,vid_type=FIXED_STRING(32));
USE repro;
CREATE TAG person(name string);
CREATE EDGE knows(p int);
-- Wait for the schema to propagate to storage via heartbeat before inserting.
INSERT VERTEX person(name) VALUES "A":("A"), "B":("B"), "AB":("AB"), "BC":("BC"), "C":("C");
INSERT EDGE knows(p) VALUES "A"->"B"@0:(1), "A"->"BC"@0:(1), "AB"->"C"@0:(1);

MATCH (a:person)-[e:knows]->(b:person)
WHERE id(a)=="A" AND id(b)=="BC"
WITH e
MATCH (c:person)-[e:knows]->(d:person)
WHERE id(c)=="AB" AND id(d)=="C"
RETURN count(*) AS c;

Expected behavior: e denotes a single edge, and the stored edges "A"->"BC" and "AB"->"C" differ in their source and destination, so no assignment satisfies both MATCH clauses:

c=0

Actual behavior:

c=1

The same happens when the two MATCH clauses are written back to back without WITH. In the same space:

ngql
MATCH (a:person)-[e:knows]->(b:person)
WHERE id(a)=="A" AND id(b)=="BC"
MATCH (c:person)-[e:knows]->(d:person)
WHERE id(c)=="AB" AND id(d)=="C"
RETURN id(a) AS aid, id(b) AS bid, src(e) AS esrc, dst(e) AS edst,
       type(e) AS etype, rank(e) AS erank, id(c) AS cid, id(d) AS did;

Expected behavior: no row is returned, since the shared e cannot be both edges:

(empty result)

Actual behavior: one row is returned, merging the endpoints pinned by the first MATCH with those pinned by the second:

aid="A", bid="BC", esrc="A", edst="BC", etype="knows", erank=0, cid="AB", did="C"

This suggests that the join key used for the shared edge variable concatenates the string VIDs of the endpoints without a separator, so "A"+"BC" and "AB"+"C" collide and two distinct edges are accepted as one. The identity of an edge should instead be its full (src, dst, type, rank) quadruple, under which these two edges are different.