edgedb-cli icon indicating copy to clipboard operation
edgedb-cli copied to clipboard

Better handling of error spans from schema objects

Open msullivan opened this issue 8 months ago • 2 comments

warning: QueryError
  ┌─ <895e407e-2614-11f0-8abe-7f96c9e30a51 expr>:2:45
  │  
2 │     __scope_0_defaultcurrentUser := (GLOBAL default::currentUser)
  │ ╭─────────────────────────────────────────────^
3 │ │ SELECT __scope_0_defaultcurrentUser {
  │ ╰─────────────────────────────^ possibly more than one element returned by an expression in a FILTER clause

Here, <895e407e-2614-11f0-8abe-7f96c9e30a51 expr> is indicating that the source of the error span is from the expr field of the schema object with id 895e407e-2614-11f0-8abe-7f96c9e30a51, and not from the base query itself.

We should avoid highlighting in the query itself in that case, and maybe could eventually consider querying the schema to get source?

Oh, or maybe we should extend the protocol to know how to collect those sources and bundle them?

msullivan avatar Apr 30 '25 22:04 msullivan

A full repro:

_localdev:main> create global foo := (select 'loooooooooooooooool' filter {true, false});
OK: CREATE GLOBAL
_localdev:main> select global foo;
warning: QueryError
  ┌─ <1b5d6448-2616-11f0-a5d1-871f8fc8d649 expr>:1:19
  │
1 │ select global foo;
  │                     possibly more than one element returned by an expression in a FILTER clause

{'loooooooooooooooool'}

msullivan avatar Apr 30 '25 22:04 msullivan

Though, two caveats I need to think about:

  • Sometimes the source isn't getting sent right anyway. I've seen cases where the source was listing as <query> until I restarted the server, and then it worked, but obviously that wasn't necessary in the case above
  • We actually should probably not be generating these warnings inside schema things anyway.

msullivan avatar May 02 '25 21:05 msullivan