[ 
https://issues.apache.org/jira/browse/TINKERPOP-3072?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17840050#comment-17840050
 ] 

Florian Hockmann commented on TINKERPOP-3072:
---------------------------------------------

I just checked how Gremlin-Python behaves in this scenario and it also throws 
an exception which is very similar to the behavior we now have with .NET 8:
{code:python}
 >>> g.V().has('name','doesnotexist').next()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "[...]\site-packages\gremlin_python\process\traversal.py", line 117, in 
next
    return self.__next__()
           ^^^^^^^^^^^^^^^
  File "[...]\site-packages\gremlin_python\process\traversal.py", line 50, in 
__next__
    self.last_traverser = next(self.traversers)
                          ^^^^^^^^^^^^^^^^^^^^^
StopIteration{code}

So, I think we should really also throw an exception for this scenario in .NET 
to be consistent across GLVs. The downside is of course that this is a breaking 
change, but only for users on .NET versions earlier than .NET 8 which is the 
current LTS version.
I'll start a thread on the dev list to discuss how we want to deal with this as 
we could either add the breaking change already on 3.6.8 / 3.7.3 or wait for 
3.8.0.

> Gremlin.Net Traversal enumeration error if element does not exist on .NET 8
> ---------------------------------------------------------------------------
>
>                 Key: TINKERPOP-3072
>                 URL: https://issues.apache.org/jira/browse/TINKERPOP-3072
>             Project: TinkerPop
>          Issue Type: Bug
>          Components: dotnet
>    Affects Versions: 3.6.7, 3.7.2
>            Reporter: Florian Hockmann
>            Priority: Major
>
> Similar to TINKERPOP-3029, one can unfortunately still get traversal 
> enumeration errors on .NET 8 with Gremlin.Net if {{Next()}} is called when 
> there is no element.
> Example:
> {code:java}
> g.V().Has("Name", "doesnotexist").Next(); {code}
> This will throw the following error:
> {code:java}
> System.InvalidOperationException: Enumeration already finished. {code}
> With .NET versions earlier than .NET 8, we simply got {{null}} back here 
> instead of the exception.
> I am not sure what the correct behavior here is. The same traversal throws a 
> {{NoSuchElementException}} with Gremlin-Java:
> {code:java}
>  gremlin> g.V().has('name','doesnotexist').next()
> java.util.NoSuchElementException{code}
> I think Gremlin.Net should either throw a similar exception which clearly 
> states the problem (instead of the {{InvalidOperationException}} which looks 
> like a bug) or return {{{}null{}}}, but it should definitely do that 
> consistently, irrespective of the version of .NET. If we decide on throwing 
> an exception in this case, then users probably have to change their code to 
> always check for element existence first via {{{}HasNext(){}}}.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to