GithubHelp home page GithubHelp logo

rest-neo4p's People

Contributors

anton-itea-javaadv-repo avatar dabedotcom avatar htbaa avatar johannessen avatar majensen avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

rest-neo4p's Issues

Unable to connect to neo4j v3.5.x with REST::Neo4p v0.4001

Hello,
I just upgraded REST::Neo4p from v0.3030 and getting On version pre-check: 401 Unauthorized when connecting to neo4j v3.5.x. Digging through the source code, noticed that module isn't passing Authorization header.

Per https://neo4j.com/docs/developer-manual/current/http-api/authentication/, /db/data seems to be an authenticated endpoint and need to pass Authorization header (not sure if this is applicable only to v3.x as I can query neo4j version anonymously with 4.x).

Is this an easy fix for you or do you want me to supply a patch?

Thanks!

Driver agent may discard statements before they have executed

The Neo4j driver API doesn’t guarantee that the server has completed executing a statement by the time the run() method returns. If you require a statement to have executed by a certain point, for example to check for errors, you need to use the result in some form. For the Perl driver, this is documented at Neo4j::Driver::Transaction.

REST::Neo4p::Agent::Neo4j::Driver currently doesn’t do that in run_in_session() or run_in_transaction():

try {
  $self->{_last_result} = $tx->run($qry, $params);
};
$self->maybe_throw_neo4p_error;

Statement execution might not even have begun on the server by the time maybe_throw_neo4p_error() is called. This may mask error reporting in certain cases.

When used with HTTP JSON, this is not an issue, because the result is always detached immediately. This is different for Bolt and Jolt.

When running the test suite on Bolt, the following test in 050_v2_schema.t fails because of this:

throws_ok { $n2->set_property({ name => "Fred" }) } 'REST::Neo4p::ConflictException', 'setting non-unique name property throws conflict exception';
# expecting: REST::Neo4p::ConflictException
# found: normal exit

Deprecation of legacy numeric IDs by Neo4j 5

Neo4j 5 deprecates the numeric IDs used as entity table key by Neo4p.

Regrettably, Jolt v2 has already removed the numeric IDs entirely (unlike Bolt v5, which provides both the legacy numeric ID and the new element ID). While it isn’t hard to determine the numeric ID from an element ID in Neo4j 5.3, doing so relies on undocumented behaviour that explicitly is subject to change in future Neo4j versions. This puts me in a bit of a bind, because I have no control over if or when the id() method will start to fail for users of the driver.

I’d like to add a deprecation warning to id() sooner rather than later to get people to change their code to use element_id() instead. However, I’m not sure how feasible it would be to change Neo4p to use string-based IDs.

Continuing use of the legacy numeric ID and just slapping no warnings qw(deprecated); all over Neo4p’s Neo4j::Driver agent should be an easy short term fix, but might well cause issues later on when/if a future Neo4j version changes in a way that prevents the driver from determining the legacy ID.

@majensen How would you like to handle this for Neo4p?

Initial implementation landed, see ["Type system customisation" in Neo4j::Driver 0.14](https://metacpan.org/pod/release/AJNN/Neo4j-Driver-0.14/lib/Neo4j/Driver.pm#Type-system-customisation). Would @majensen consider this suitable for adapting REST::Neo4p to use Neo4j::Driver? Are any other changes to Neo4j::Driver necessary (or perhaps just useful)?

Initial implementation landed, see "Type system customisation" in Neo4j::Driver 0.14. Would @majensen consider this suitable for adapting REST::Neo4p to use Neo4j::Driver? Are any other changes to Neo4j::Driver necessary (or perhaps just useful)?

Originally posted by @johannessen in johannessen/neo4j-driver-perl#4 (comment)

Can't locate object method "rethrow" via package "Mojo::Exception" at REST/Neo4p/Query.pm line 117.

When using Mojo::UserAgent I sometimes get an exception with the error message from the title. Mojo::Exception doesn't have a rethrow subroutine.

112:     $self->{_error} = $e;
113:     $e->rethrow if ($self->{RaiseError});
114:     return;
115:   }
116:   elsif ( $e = Exception::Class->caught) {
117:     ref $e ? $e->rethrow : die $e;
118:   }
119:   my $jsonr = JSON::XS->new;
120:   my ($buf,$res,$str,$rowstr,$obj);
121:   my $row_count;
122:   use experimental 'smartmatch';

Connecting to GrapheneDB with perl driver

Hi, I am going through your blog post tutorial and trying to connect to a sandbox instance of Neo4j on GrapheneDB. Unfortunately I keep getting an 'Unauthorized' error. I am using the basic connection string

REST::Neo4p->connect( $server, $user, $pass );

with my appropriate host URL, username, and password as specified in my GrapheneDB console's connection tab. What am I missing here?

Here is my exact connection snippet.

eval {
REST::Neo4p->connect($url, $username, $password);
};
ref $@ ? $@->rethrow : die $@ if $@;

Thanks in advance.

Can't open file "/tmp/a9mCPkqcRm": Too many open files at

Hi, another issue I'm running into. I noticed that many temporary files are created, because they're not cleaned up after. Resulting in the error message from the title. The context I'm running REST::Neo4p in is a Mojolicious webapplicatie running behind Hypnotoad and the Minion job worker. I'm not using REST::Neo4p directly but through DBD::Neo4j.

I'm not calling $sth->finish() because I remember reading that's not something you're supposed to do...

Smartmatch is deprecated

I’m not sure if you’re aware of the long-standing efforts to remove the smartmatch feature from Perl. Perl v5.37.10 will finally start to issue deprecation warnings for it. Testing Neo4p in Perl blead today yields the following:

given is deprecated at lib/REST/Neo4p/Agent.pm line 214.
when is deprecated at lib/REST/Neo4p/Agent.pm line 215.
when is deprecated at lib/REST/Neo4p/Agent.pm line 239.
given is deprecated at lib/REST/Neo4p/Agent.pm line 276.
when is deprecated at lib/REST/Neo4p/Agent.pm line 277.
when is deprecated at lib/REST/Neo4p/Agent.pm line 280.
given is deprecated at lib/REST/Neo4p/ParseStream.pm line 32.
when is deprecated at lib/REST/Neo4p/ParseStream.pm line 33.
when is deprecated at lib/REST/Neo4p/ParseStream.pm line 36.
given is deprecated at lib/REST/Neo4p/ParseStream.pm line 152.
when is deprecated at lib/REST/Neo4p/ParseStream.pm line 153.
when is deprecated at lib/REST/Neo4p/ParseStream.pm line 160.
when is deprecated at lib/REST/Neo4p/ParseStream.pm line 165.
when is deprecated at lib/REST/Neo4p/ParseStream.pm line 172.
when is deprecated at lib/REST/Neo4p/ParseStream.pm line 181.
when is deprecated at lib/REST/Neo4p/ParseStream.pm line 195.
when is deprecated at lib/REST/Neo4p/ParseStream.pm line 205.
when is deprecated at lib/REST/Neo4p/ParseStream.pm line 227.
given is deprecated at lib/REST/Neo4p/Batch.pm line 46.
when is deprecated at lib/REST/Neo4p/Batch.pm line 47.
when is deprecated at lib/REST/Neo4p/Batch.pm line 67.
when is deprecated at lib/REST/Neo4p/Batch.pm line 71.

The test suite still seems to pass though. So, no immediate action is required. But the current plan is to remove the feature entirely with Perl v5.42 in 2025.

Good old if/elsif/else chains are a possible replacement. for blocks can sometimes be useful as a direct replacement for given, although next will behave differently inside of them. There are also a number of CPAN modules that offer C-style switch/case syntax, of which Syntax::Keyword::Match might be one of the more interesting, in spite of it currently being experimental.

Query: Parsing collect() results sometimes fails

Hi Mark,

I discovered REST::Neo4p is unable to parse the result of certain Cypher queries that use expressions calling Neo4j functions like collect() in the RETURN clause. Minimized example:

# set up graph for testing
my $q1 = REST::Neo4p::Query->new(<<END);
CREATE (a:Test)-[:TEST{test:true}]->(:Test)
RETURN id(a)
END
$q1->execute();
my $id = $q1->fetch->[0];

# test collecting properties that are undefined
my $q2 = REST::Neo4p::Query->new(<<END);
MATCH (p:Test)-[r]-(o) WHERE id(p) = {id}
RETURN collect(r.void)
END
$q2->execute(id => $id);
print Dumper $q2->fetch->[0];  # expected: []
# dies: Can't use an undefined value as an ARRAY reference at REST/Neo4p/Query.pm line 428.

# test collecting properties that have boolean values
my $q3 = REST::Neo4p::Query->new(<<END);
MATCH (p:Test)-[r]-(o) WHERE id(p) = {id}
RETURN collect(r.test)
END
$q3->execute(id => $id);
print Dumper $q3->fetch->[0];  # expected: [true]
# dies: Not a HASH reference at REST/Neo4p/Query.pm line 358.

This issue is reproducible for REST::Neo4p 0.3020 with Neo4j versions 2.3.3, 3.0.0 and 3.3.5.

I worked around this issue by simplifying my queries, so I don’t need a fix at this time. But I still wanted to document it.

Furthermore I clearly remember having similar problems with the substring() function. Which is quite mystifying since producing a simple string is of course all it does, and I fail to see why e. g. substring('1999-12-31', 0, 4) would fail where '1999' succeeds. However, I now seem to be unable to reproduce this issue, so I suppose it’s not just possible, but in fact probable I simply made a mistake of some sort there.

Cheers,
Arne

Unauthorized on connect to Neo4j 2/3

Two different failure modes exist in REST::Neo4p 0.4000 when connecting to Neo4j version 2 or 3:

REST::Neo4p->connect("http://$host:7474", $user, $password);
# LWP::UserAgent   dies:  On version pre-check: 401 Unauthorized at …/REST/Neo4p.pm line 175.
# Mojo::UserAgent  dies:  On version pre-check: 401 Unauthorized at …/REST/Neo4p.pm line 175.
# HTTP::Thin       dies:  Internal Exception
# Neo4j::Driver    dies:  On version pre-check: 401 Unauthorized at …/REST/Neo4p.pm line 175.
REST::Neo4p->connect("http://$user:$password\@$host:7474");
# LWP::UserAgent   dies:  Unauthorized (connect phase 2)
# Mojo::UserAgent  dies:  Unauthorized (connect phase 2)
# HTTP::Thin       dies:  Internal Exception
# Neo4j::Driver    works!

The workaround is to specify the credentials twice like this:

REST::Neo4p->connect("http://$user:$password\@$host:7474", $user, $password);
# LWP::UserAgent   works!
# Mojo::UserAgent  works!
# HTTP::Thin       dies:  Internal Exception
# Neo4j::Driver    works!

(Not sure what is going on with HTTP::Thin. Haven’t bothered to investigate further.)

Unsupported/experimental call to keys() of driver result in scalar context

REST::Neo4p::Query->_wrap_statement_result() makes a call to Neo4j::Driver::Result->keys() in scalar context.

$self->{NAME} = $result->keys;

Calling keys() in scalar context is experimental. At present, it returns the number of columns in the result rather than an array reference – in other words, it now behaves like a Perl list variable.

I’m eager to hear feedback on scalar context behaviour, for the driver as well as for Neo4j::Types.

To call keys() in a stable way, use list context.

Can't connect to neo4j(latest version)

REST::Neo4p does not support the latest version of Neo4j?
When I use the latest version of Neo4j, I get the following error.

"URL missing (connect phase 2)"

It seems to be directly caused by the fact that the URL is not set at the time of the second connection, although it is connected twice in the process of doing "&connect()”.

$resp = $self->get($self->{_actions}{data});

"&connect()" is trying to get the URL from the response on the first connection, but since it doesn't return the "data" field, I guess the URL is not set on the second connection.

Thanks!

query one db, then connect to and query a second

I'm trying to restore some data on several remote servers from local backups (and wholesale replacement of neo's data directory is not an option). But REST::Neo4p seems to run into problems when I try doing something like this:

use strict;
use warnings;
use 5.010;
use Data::Dumper;
use REST::Neo4p;

{
  REST::Neo4p->connect('http://127.0.0.1:7474');
  my $q = REST::Neo4p::Query->new('match (l:Language) return l');
  $q->{ResponseAsObjects} = 0;
  $q->execute;
  my %langs = map {$_->{_name} => $_} @{$q->fetch};
  $q->finish;
  say Dumper(\%langs);

  REST::Neo4p->connect($remote_url);
  $q = REST::Neo4p::Query->new('match (l:Language)<-(h:Hint) return l,h');
  $q->{ResponseAsObjects} = 0;
  $q->execute;
  say Dumper($q->fetch);
}

The Dump of %langs is what I expect. But then I get the error:
Can't run fetch(), query not execute()'d yet

I'm very confused as to why it says the query wasn't executed()'d yet. It seems like I'd just executed it. Any ideas?

Add support to REST::Neo4p to pass dbname to Neo4j::Driver agent

Hello,
Neo4j::Driver agent accepts server address and dbname for it's connect() method but REST::Neo4p doesn't have support to pass dbname to the agent. This is needed to work with v4.x version where we can have multiple databases in a single instance.

Happy to submit a patch if you prefer or please do the needful.

Thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.