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

More informative errors for neuprint_fetch_custom? #38

Closed
romainFr opened this issue Jan 27, 2020 · 6 comments · Fixed by #44
Closed

More informative errors for neuprint_fetch_custom? #38

romainFr opened this issue Jan 27, 2020 · 6 comments · Fixed by #44
Assignees

Comments

@romainFr
Copy link
Collaborator

In neuprint explorer, you get error messages that detail why a given query fails. If there's a way to grab those through the API that would be more useful that the HTTP error codes we're now getting.

@jefferis
Copy link
Contributor

@romainFr If you give me a query with error, can show you how to get that.

@jefferis
Copy link
Contributor

@romainFr can you give an example here?

@romainFr
Copy link
Collaborator Author

If I run a large query, in neuprint explorer I'd get a message expliciting that the problem is a time out (this happens with path queries easily):

Error: Post http://neo4j:[email protected]:7474/db/data/transaction: net/http: request canceled (Client.Timeout exceeded while awaiting headers)

Whereas in neuprintr, we only return Bad Request (HTTP 400).
In general anywhere we get a 'Bad Request`, I'm wondering if there's a way to obtain the server error message.

(other example, when querying a shortest path with identical neurons in the input and output side, we get a bad request, whereas neuprint explorer returns:

Error: The shortest path algorithm does not work when the start and end nodes are the same. This can happen if you perform a shortestPath search after a cartesian product that might have the same start and end nodes for some of the rows passed to shortestPath. If you would rather not experience this exception, and can accept the possibility of missing results for those rows, disable this in the Neo4j configuration by setting cypher.forbid_shortestpath_common_nodes to false. If you cannot accept missing results, and really want the shortestPath between two common nodes, then re-write the query using a standard Cypher variable length pattern expression followed by ordering by path length and limiting to one result.
)

@jefferis
Copy link
Contributor

Thanks @romainFr. But can you give an actual R snippet that fails?

@jefferis
Copy link
Contributor

I think the issue is that the server returns an error code which triggers an R error before we ever get to inspect the details of the request to extract more information.

neuprintr/R/fetch.R

Lines 15 to 26 in ea20c16

httr::stop_for_status(req)
if (parse.json) {
parsed = neuprint_parse_json(req, simplifyVector = simplifyVector)
if (length(parsed) == 2 && isTRUE(names(parsed)[2] =="error")) {
stop("neuPrint error: ", parsed$error)
}
if (include_headers) {
fields_to_include = c("url", "headers")
attributes(parsed) = c(attributes(parsed), req[fields_to_include])
}
parsed
}

Basically if we get a 400 status instead of throwing an error immediately we should extract the error details and then throw the error.

@romainFr
Copy link
Collaborator Author

neuprint_get_paths(c(1128092885,481121605),5813041365,3,weightT=20,all_segments = FALSE) will give the time out for example

@jefferis jefferis self-assigned this Jan 27, 2020
jefferis added a commit that referenced this issue Jan 27, 2020
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.

2 participants