edgedb icon indicating copy to clipboard operation
edgedb copied to clipboard

6.5 ISE/AssertionError with partial path in mutation rewrite

Open CarsonF opened this issue 8 months ago • 1 comments

  • Gel Version: 6.5
  • Gel CLI Version:
  • OS Version:

Steps to Reproduce:

departmentId: str {
  rewrite insert, update using (
    ...
    if __subject__ is MultiplicationTranslationProject then (
      assert_exists(
        (select __subject__.partnerships filter .primary).partner,
        message := "Project must have a primary partnership"
      )
    ) else (...)
  );
}

Partnership.primary is what I'm trying to reference, not MultiplicationTranslationProject.primary

schema src

AssertionError: object type 'default::MultiplicationTranslationProject' has no link or property 'primary'

InternalServerError: AssertionError: object type 'default::MultiplicationTranslationProject' has no link or property 'primary'
  Server traceback:
      Traceback (most recent call last):
        File "edb/server/compiler_pool/worker.py", line 180, in compile
          units, cstate = COMPILER.compile_serialized_request(
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "edb/server/compiler/compiler.py", line 606, in compile_serialized_request
          return self.compile(
                 ^^^^^^^^^^^^^
        File "edb/server/compiler/compiler.py", line 685, in compile
          unit_group = compile(ctx=ctx, source=request.source)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "edb/server/compiler/compiler.py", line 2609, in compile
          return _try_compile(ctx=ctx, source=source)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "edb/server/compiler/compiler.py", line 2783, in _try_compile
          return _try_compile_ast(statements=statements, source=source, ctx=ctx)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "edb/server/compiler/compiler.py", line 2835, in _try_compile_ast
          comp, capabilities = _compile_dispatch_ql(
                               ^^^^^^^^^^^^^^^^^^^^^
        File "edb/server/compiler/compiler.py", line 2514, in _compile_dispatch_ql
          query = ddl.compile_dispatch_ql_migration(
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "edb/server/compiler/ddl.py", line 448, in compile_dispatch_ql_migration
          return _start_migration(ctx, ql, in_script)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "edb/server/compiler/ddl.py", line 528, in _start_migration
          target_schema, warnings = s_ddl.apply_sdl(
                                    ^^^^^^^^^^^^^^^^
        File "edb/schema/ddl.py", line 585, in apply_sdl
          process(ddl_stmt)
        File "edb/schema/ddl.py", line 522, in process
          target_schema = delta.apply(target_schema, context)
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "edb/schema/delta.py", line 1631, in apply
          schema = self.apply_subcommands(schema, context)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "edb/schema/delta.py", line 993, in apply_subcommands
          schema = op.apply(schema, context=context)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "edb/schema/delta.py", line 3644, in apply
          schema = self._alter_innards(schema, context)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "edb/schema/delta.py", line 3318, in _alter_innards
          return self.apply_subcommands(schema, context)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "edb/schema/delta.py", line 993, in apply_subcommands
          schema = op.apply(schema, context=context)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "edb/schema/delta.py", line 3217, in apply
          schema = self._create_begin(schema, context)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "edb/schema/referencing.py", line 1104, in _create_begin
          return super()._create_begin(schema, context)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "edb/schema/referencing.py", line 672, in _create_begin
          schema = super()._create_begin(schema, context)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "edb/schema/inheriting.py", line 774, in _create_begin
          schema = super()._create_begin(schema, context)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "edb/schema/delta.py", line 3096, in _create_begin
          schema = self.canonicalize_attributes(schema, context)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "edb/schema/triggers.py", line 141, in canonicalize_attributes
          expression = self.compile_expr_field(
                       ^^^^^^^^^^^^^^^^^^^^^^^^
        File "edb/schema/triggers.py", line 231, in compile_expr_field
          return type(value).compiled(
                 ^^^^^^^^^^^^^^^^^^^^^
        File "edb/schema/expr.py", line 240, in compiled
          ir = qlcompiler.compile_ast_to_ir(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "edb/edgeql/compiler/__init__.py", line 188, in wrapper
          return func(*args, **kwargs)
                 ^^^^^^^^^^^^^^^^^^^^^
        File "edb/edgeql/compiler/__init__.py", line 283, in compile_ast_to_ir
          ir_set = dispatch_mod.compile(tree, ctx=ctx)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "edgedb/portable/6.5/lib/python3.12/functools.py", line 909, in wrapper
          return dispatch(args[0].__class__)(*args, **kw)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "edb/edgeql/compiler/stmt.py", line 708, in compile_UpdateQuery
          conflicts.check_for_isolation_conflicts(
        File "edb/edgeql/compiler/conflicts.py", line 917, in check_for_isolation_conflicts
          entries = _get_type_conflict_constraint_entries(stmt, typ, ctx=ctx)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "edb/edgeql/compiler/conflicts.py", line 727, in _get_type_conflict_constraint_entries
          _get_needed_ptrs(typ, (), [name], rewrite_kind, ctx)[0]
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "edb/edgeql/compiler/conflicts.py", line 81, in _get_needed_ptrs
          ptr = subject_typ.getptr(ctx.env.schema, s_name.UnqualName(p))
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "edb/schema/sources.py", line 140, in getptr
          raise AssertionError(
      AssertionError: object type 'default::MultiplicationTranslationProject' has no link or property 'primary'

This works fine on 6.4. So this was introduced in 6.5+

CarsonF avatar Apr 24 '25 13:04 CarsonF

Still seems to be an issue in 6.9.

bryanjnelson avatar Jun 27 '25 18:06 bryanjnelson