Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UnresolvedReferenceError: reference to an undefined item default::null in default::MyType@is_initial_revision #7256

Closed
jimkring opened this issue Apr 25, 2024 · 4 comments · Fixed by #7351
Assignees

Comments

@jimkring
Copy link

I'm using a recursive type and it seems to cause some issues. It was working OK until I added the is_initial_revision := .parent_revision is null; computed field...

  • EdgeDB Version: 5.2+ddd8aa4
  • EdgeDB CLI Version: 5.0.0+ef02158
  • OS Version: Windows 10

I'm trying to create a migration with this type in it:

type MyType {
  parent_revision: MyType;
  multi child_revisions := .<parent_revision[is MyType];
  is_latest_revision := count(.child_revisions) = 0;
  is_initial_revision := .parent_revision is null;
}

When I try to create a migration, I get the following error:

edgedb error: InternalServerError: UnresolvedReferenceError: reference to an undefined item default::null in default::MyType@is_initial_revision
  Hint: This is most likely a bug in EdgeDB. Please consider opening an issue ticket at https://github.com/edgedb/edgedb/issues/new?template=bug_report.md
  Server traceback:
      Traceback (most recent call last):
        File "/home/edgedb/.local/share/edgedb/portable/5.2/lib/python3.12/site-packages/edb/server/compiler_pool/worker.py", line 178, in compile
          units, cstate = COMPILER.compile_request(
                          ^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/home/edgedb/.local/share/edgedb/portable/5.2/lib/python3.12/site-packages/edb/server/compiler/compiler.py", line 857, in compile_request
          units, cstate = self.compile(
                          ^^^^^^^^^^^^^
        File "/home/edgedb/.local/share/edgedb/portable/5.2/lib/python3.12/site-packages/edb/server/compiler/compiler.py", line 937, in compile
          unit_group = compile(ctx=ctx, source=source)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/home/edgedb/.local/share/edgedb/portable/5.2/lib/python3.12/site-packages/edb/server/compiler/compiler.py", line 2585, in compile
          return _try_compile(ctx=ctx, source=source)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/home/edgedb/.local/share/edgedb/portable/5.2/lib/python3.12/site-packages/edb/server/compiler/compiler.py", line 2663, in _try_compile
          comp, capabilities = _compile_dispatch_ql(
                               ^^^^^^^^^^^^^^^^^^^^^
        File "/home/edgedb/.local/share/edgedb/portable/5.2/lib/python3.12/site-packages/edb/server/compiler/compiler.py", line 2490, in _compile_dispatch_ql
          query = ddl.compile_dispatch_ql_migration(
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/home/edgedb/.local/share/edgedb/portable/5.2/lib/python3.12/site-packages/edb/server/compiler/ddl.py", line 386, in compile_dispatch_ql_migration
          return _start_migration(ctx, ql, in_script)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/home/edgedb/.local/share/edgedb/portable/5.2/lib/python3.12/site-packages/edb/server/compiler/ddl.py", line 466, in _start_migration
          target_schema = s_ddl.apply_sdl(
                          ^^^^^^^^^^^^^^^^
        File "/home/edgedb/.local/share/edgedb/portable/5.2/lib/python3.12/site-packages/edb/schema/ddl.py", line 591, in apply_sdl
          ddl_stmts = s_decl.sdl_to_ddl(target_schema, documents)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/home/edgedb/.local/share/edgedb/portable/5.2/lib/python3.12/site-packages/edb/edgeql/declarative.py", line 471, in sdl_to_ddl
          ordered = topological.sort(ddlgraph, allow_unresolved=False)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/home/edgedb/.local/share/edgedb/portable/5.2/lib/python3.12/site-packages/edb/common/topological.py", line 210, in sort
          items = sort_ex(graph, allow_unresolved=allow_unresolved)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/home/edgedb/.local/share/edgedb/portable/5.2/lib/python3.12/site-packages/edb/common/topological.py", line 134, in sort_ex
          raise UnresolvedReferenceError(
      edb.common.topological.UnresolvedReferenceError: reference to an undefined item default::null in default::MyType@is_initial_revision
@elprans
Copy link
Member

elprans commented Apr 25, 2024

Error presentation (ISE) is a bug, but the actual issue is that there is not a thing named null in EdgeDB. You want not exists .parent_revision instead.

@jimkring
Copy link
Author

Thanks @elprans

@1st1
Copy link
Member

1st1 commented Apr 26, 2024

We should special-case the "null"
name to print an error with a hint that EdgeDB doesn't have null and explain what to do

@msullivan
Copy link
Member

msullivan commented Apr 26, 2024

Two things here:

  1. The bug specifically seems to be in handling unresolved names in type expressions (which null is one of in ... is null, since E IS T checks if the LHS is of type T). If you write = null instead we produce a proper error message
  2. Yury's idea of giving a hint about null is a good one

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants