#6169·nebula

`startNode()` and `endNode()` return the pattern traversal endpoints instead of the stored edge's endpoints in a reversed `MATCH` pattern

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 startNode() and endNode() return the endpoints of the pattern traversal rather than the endpoints of the stored edge when the edge is matched by a reversed pattern such as (a)<-[e]-(b).

In the example below the only stored edge is "A"->"B": src(e)/dst(e) correctly report "A"/"B", but startNode(e)/endNode(e) return "B"/"A", following the direction of the reversed pattern. startNode(e)/endNode(e) should denote the source and destination of the stored edge e itself, independent of the direction in which the pattern was written.

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");
INSERT EDGE knows(p) VALUES "A"->"B"@0:(1);

MATCH (a:person)<-[e:knows]-(b:person)
WHERE id(a)=="B" AND id(b)=="A"
RETURN src(e) AS src, dst(e) AS dst,
       id(startNode(e)) AS start, id(endNode(e)) AS end;

Expected behavior: the only stored edge is "A"->"B", so all four expressions report that edge's endpoints:

src="A", dst="B", start="A", end="B"

Actual behavior: src(e)/dst(e) are correct but startNode(e)/endNode(e) are swapped, following the reversed pattern direction:

src="A", dst="B", start="B", end="A"

This also affects WHERE filtering. In the same space, with the additional vertices "AB", "BC", "C" and the two additional knows edges below:

ngql
INSERT VERTEX person(name) VALUES "AB":("AB"), "BC":("BC"), "C":("C");
INSERT EDGE knows(p) VALUES "A"->"BC"@0:(1), "AB"->"C"@0:(1);

MATCH (a:person)<-[e:knows]-(b:person)
WHERE id(startNode(e)) == id(b)
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;

Expected behavior: in the reversed pattern (a)<-[e]-(b), b is the stored edge's source, so id(startNode(e)) == id(b) holds for every match and all three rows are returned:

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

Actual behavior:

(empty result)

This suggests that startNode()/endNode() are resolved from the direction in which the pattern was traversed rather than from the stored edge, so under a reversed edge pattern they disagree with src(e)/dst(e), and predicates that compare them against the pattern endpoints reject every match.